package com.miracle9.game.service;

import com.miracle9.game.bean.Pager;
import com.miracle9.game.bean.RoomStatus;
import com.miracle9.game.dao.*;
import com.miracle9.game.entity.*;
import com.miracle9.game.enums.GameTypeEnums;
import com.miracle9.game.server.message.AmfMessageSend;
import com.miracle9.game.server.message.*;
import com.miracle9.game.util.*;
import net.sf.json.JSONArray;
import org.apache.log4j.Logger;
import org.apache.mina.core.session.IoSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

@Service("deskService")
public class DeskService extends BaseService {

    private Logger logger = Logger.getLogger(DeskService.class);
    @Autowired
    private HallInfoDao hallInfoDao;
    @Autowired
    private FishHallInfoDao fishHallInfoDao;
    @Autowired
    private CardHallInfoDao cardHallInfoDao;
    @Autowired
    private WaterHallInfoDao waterHallInfoDao;
    @Autowired
    private BulletFishHallInfoDao bulletFishHallInfoDao;
    @Autowired
    private LiKuiFishHallInfoDao liKuiFishHallInfoDao;
    @Autowired
    private TianGongHallInfoDao tianGongHallInfoDao;
    @Autowired
    private MermaidFishHallInfoDao mermaidFishHallInfoDao;
    @Autowired
    private GoldenCicadaFishHallInfoDao goldenCicadaFishHallInfoDao;
    @Autowired
    private GoldSharkHallInfoDao goldSharkHallInfoDao;
    @Autowired
    private DeskServiceDao deskServiceDao;
    @Autowired
    private RoomServiceDao roomServiceDao;
    @Autowired
    private com.miracle9.game.dao.AdminServiceDao adminServiceDao;
    @Autowired
    private com.miracle9.game.dao.AdminLogServiceDao adminLogServiceDao;
    @Autowired
    private DeskResultServiceDao deskResultServiceDao;
    @Autowired
    private FishKingDB fishKingDB;
    @Autowired
    private FishKingRoomDB fishKingRoomDB;
    @Autowired
    private LiKuiFishDeskDao liKuiFishDeskDao;
    @Autowired
    private GoldenCicadaFishDeskDao goldenCicadaFishDeskDao;
    @Autowired
    private FishDeskServiceDao fishDeskServiceDao;
    @Autowired
    private ThousandFishDeskDao thousandFishDeskDao;
    @Autowired
    private SystemConfigServiceDao systemConfigServiceDao;
    @Autowired
    private FishRoomServiceDao fishRoomServiceDao;
    @Autowired
    private ThousandFishRoomDao thousandFishRoomDao;
    @Autowired
    private FishDeskResultServiceDao fishDeskResultServiceDao;
    @Autowired
    private ThousandFishDeskResultDao thousandFishDeskResultDao;
    @Autowired
    private CardParameterServiceDao cardParameterServiceDao;
    @Autowired
    private UserServiceDao userServiceDao;
    @Autowired
    private CardDeskServiceDao cardDeskServiceDao;
    @Autowired
    private CardRoomServiceDao cardRoomServiceDao;
    @Autowired
    private CardDeskResultServiceDao cardDeskResultServiceDao;
    @Autowired
    private FishKingDeskResultDB fishKingDeskResultDB;
    @Autowired
    private com.miracle9.game.dao.BulletFishDeskServiceDao bulletFishDeskServiceDao;
    @Autowired
    private com.miracle9.game.dao.BulletFishRoomServiceDao bulletFishRoomServiceDao;
    @Autowired
    private MermaidDeskServiceDao mermaidDeskServiceDao;
    @Autowired
    private MermaidRoomServiceDao mermaidRoomServiceDao;
    @Autowired
    private MermaidDeskResultServiceDao mermaidDeskResultServiceDao;
    @Autowired
    private LackDeskServiceDao lackDeskServiceDao;
    @Autowired
    private LackRoomServiceDao lackRoolmServiceDao;
    @Autowired
    private LackParameterServiceDao lackParameterServiceDao;
    @Autowired
    private LackDeskResultServiceDao lackDeskResultServiceDao;
    @Autowired
    private JoyDeskServiceDao joyDeskServiceDao;
    @Autowired
    private JoyRoomServiceDao joyRoomServiceDao;
    @Autowired
    private JoyDeskResultServiceDao joyDeskResultServiceDao;
    @Autowired
    private JoyPrivateDeskParameterServiceDao joyPrivateDeskParameterServiceDao;
    @Autowired
    private WaterDeskServiceDao waterDeskServiceDao;
    @Autowired
    private RecordDeleteDeskServiceDao recordDeleteDeskServiceDao;

    public List<Desk> getAllDesk() {
        return this.deskServiceDao.getAllDesk();
    }

    public Desk getDesk(int id) {
        return this.deskServiceDao.getDesk(id);
    }

    public Desk[] getDeskList(IoSession session) {
        List<Desk> desks = this.deskServiceDao.getAllDesk();
        for (Desk d : desks) {
            d.setOnlineNumber(0);
            List<User> us = GameParameterAssist.bm.get(d.getId());
            if (us != null) {
                d.setOnlineNumber(us.size());
            }
        }
        return desks.toArray(new Desk[0]);
    }

    public synchronized Map<String, Object> addDesk(Desk desk, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        int deskCount = this.deskServiceDao.getQuantityByRoomId(desk.getRoomId());
        Room r = this.roomServiceDao.getRoom(desk.getRoomId());
        if (deskCount >= r.getDeskNum()) {
            result.put("success", Boolean.FALSE);
            result.put("message", MyUtil.getProperties(resultInt(session), "deskNumOverrun"));
            return result;
        }
        int countByName = this.deskServiceDao.q_CreateSqlInt("select count(*) from Desk where name=?", new Object[]{desk.getName()});
        if (countByName > 0) {
            result.put("success", Boolean.FALSE);
            result.put("message", MyUtil.getProperties(resultInt(session), "deskNameExist"));
            return result;
        }
        Object maxOrderBy = this.deskServiceDao.q_CreateSql("select max(orderBy) from Desk where roomId=?", new Object[]{desk.getRoomId()}).uniqueResult();
        if (maxOrderBy != null) {
            desk.setOrderBy((Integer) maxOrderBy + 1);
        } else {
            desk.setOrderBy(1);
        }
        this.deskServiceDao.saveReturnInteger(desk);
        RoomStatus rs = GameParameterAssist.bD;
        if (desk.getRoomId() == 1) {
            rs.room1StartNum += 1;
            rs.room1RemainNum -= 1;
        } else {
            rs.room2StartNum += 1;
            rs.room2RemainNum -= 1;
        }
        String content = null;
        String contentEn = null;
        if (desk.getRoomId() == 1) {
            content = "幸运六狮：在练习厅添加了新桌，ID为 " + desk.getId();
            contentEn = "Lucky lion : Add a new table into practice room which ID is " + desk.getId();
        } else {
            content = "幸运六狮：在竞技厅添加了新桌，ID为 " + desk.getId();
            contentEn = "Lucky lion : Add a new table into compete room which ID is " + desk.getId();
        }
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content, 1, admin.getType(), contentEn);
        this.adminLogServiceDao.addAdminLog(adminLog);
        for (Map.Entry<Integer, IoSession> entry : GameParameterAssist.be.entrySet()) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(entry.getValue(), "syncRoomStatus", new Object[]{rs}));
        }
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        for (IoSession s : com.miracle9.game.server.message.LuckSocketHandler.A) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/addDesk", new Object[]{desk}));
        }
        SystemConfig config = this.systemConfigServiceDao.getSystemConfig();
        if (config.getOpenLuckGame() == 0) {
            this.systemConfigServiceDao.ifTypeUpdate(GameTypeEnums.GT_0.getType(), 1);
            gameRunNotice();
        }
        return result;
    }

    public Map<String, Object> updateDesk(Desk desk, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        int deskCount = this.deskServiceDao.q_CreateSqlInt("select count(*) from Desk where name=? and id!=?", new Object[]{desk.getName(), desk.getId()});
        if (deskCount > 0) {
            result.put("success", Boolean.FALSE);
            result.put("message", MyUtil.getProperties(resultInt(session), "deskNameExist"));
            return result;
        }
        Desk old = this.deskServiceDao.getDesk(desk.getId());
        if ((old.getAnimalDiff() != desk.getAnimalDiff()) || (old.getZxhDiff() != desk.getZxhDiff()) || (old.getExchange() != desk.getExchange()) || (old.getSiteType() != desk.getSiteType())) {
            this.deskServiceDao.initializeById(old.getId());
        }
        int isExitSeat = 0;
        int isLimit = 0;
        int isAutoKick = 0;
        StringBuilder content = new StringBuilder();
        StringBuilder contentEn = new StringBuilder();
        if (desk.getRoomId() == 1) {
            content.append("幸运六狮：修改了练习厅桌，ID为 " + desk.getId());
            contentEn.append("Lucky lion : Change the parameter of practice table which ID is " + desk.getId());
        } else {
            content.append("幸运六狮：修改了竞技厅桌，ID为 " + desk.getId());
            contentEn.append("Lucky lion : Change the parameter of compete table which ID is " + desk.getId());
        }
        if (!old.getName().equals(desk.getName())) {
            isLimit = 1;
            content.append("，修改名称为“" + desk.getName() + "”");
            contentEn.append(",Its name has been changed to " + desk.getName());
        }
        if (old.getMinGold() != desk.getMinGold()) {
            isLimit = 1;
            content.append("，修改最少携带为“" + desk.getMinGold() + "”");
            contentEn.append(",Change the min carry of coins to " + desk.getMinGold());
        }
        if (old.getMaxBet() != desk.getMaxBet()) {
            isLimit = 1;
            content.append("，修改动物最大押注为“" + desk.getMaxBet() + "”");
            contentEn.append(",Change the animal max bet to " + desk.getMaxBet());
        }
        if (old.getMinBet() != desk.getMinBet()) {
            isLimit = 1;
            content.append("，修改动物最小押注为“" + desk.getMinBet() + "”");
            contentEn.append(",Change the animal min bet to " + desk.getMinBet());
        }
        if (old.getMax_zx() != desk.getMax_zx()) {
            isLimit = 1;
            content.append("，修改庄闲最大押注为“" + desk.getMax_zx() + "”");
            contentEn.append(",Change the min bet of banker and player to " + desk.getMax_zx());
        }
        if (old.getMax_h() != desk.getMax_h()) {
            isLimit = 1;
            content.append("，修改和最大押注为“" + desk.getMax_h() + "”");
            contentEn.append(",Change the tie max bet to " + desk.getMax_h());
        }
        if (old.getMin_zxh() != desk.getMin_zxh()) {
            isLimit = 1;
            content.append("，修改庄闲和最小押注为“" + desk.getMin_zxh() + "”");
            contentEn.append(",Change the min bet of banker，player and tie to " + desk.getMin_zxh());
        }
        if (old.getAutoKick() != desk.getAutoKick()) {
            isAutoKick = 1;
            if (desk.getAutoKick() == 0) {
                content.append("，关闭自动踢出挂机玩家");
                contentEn.append(",Turn off the function of kicking out hang up player");
            } else {
                content.append("，开启自动踢出挂机玩家");
                contentEn.append(",Turn on the function of kicking out hang up player");
            }
        }
        if (old.getAnimalDiff() != desk.getAnimalDiff()) {
            isExitSeat = 1;
            if (desk.getAnimalDiff() == 0) {
                content.append("，修改动物几率为“易 ”");
                contentEn.append(",Change the animal probability to easy");
            } else if (desk.getAnimalDiff() == 1) {
                content.append("，修改动物几率为“中 ”");
                contentEn.append(",Change the animal probability to medium");
            } else if (desk.getAnimalDiff() == 2) {
                content.append("，修改动物几率为“难 ”");
                contentEn.append(",Change the animal probability to hard");
            } else {
                content.append("，修改动物几率为“" + desk.getAnimalDiff() + "”");
                contentEn.append(",Change the animal probability to " + desk.getAnimalDiff());
            }
        }
        if (old.getZxhDiff() != desk.getZxhDiff()) {
            isExitSeat = 1;
            if (desk.getZxhDiff() == 0) {
                content.append("，修改庄闲和几率为“易 ”");
                contentEn.append(",Change the probability of banker、player、tie to easy");
            } else if (desk.getZxhDiff() == 1) {
                content.append("，修改庄闲和几率为“中 ”");
                contentEn.append(",Change the probability of banker、player、tie to medium");
            } else if (desk.getZxhDiff() == 2) {
                content.append("，修改庄闲和几率为“难 ”");
                contentEn.append(",Change the probability of banker、player、tie to hard");
            } else {
                content.append("，修改庄闲和几率为“" + desk.getZxhDiff() + "”");
                contentEn.append(",Change the probability of banker、player、tie to " + desk.getZxhDiff());
            }
        }
        if (old.getWaterType() != desk.getWaterType()) {
            isExitSeat = 1;
            if (desk.getWaterType() == 0) {
                content.append("，修改抽水范围为“" + desk.getWaterValue() + "”");
                contentEn.append(",Change the range of extraction to " + desk.getWaterValue());
            } else {
                content.append("，修改注水范围为“" + desk.getWaterValue() + "”");
                contentEn.append(",Change the range of relaxation to " + desk.getWaterValue());
            }
        } else if (old.getWaterValue() != desk.getWaterValue()) {
            isExitSeat = 1;
            if (desk.getWaterType() == 0) {
                content.append("，修改抽水范围为“" + desk.getWaterValue() + "”");
                contentEn.append(",Change the range of extraction to " + desk.getWaterValue());
            } else {
                content.append("，修改注水范围为“" + desk.getWaterValue() + "”");
                contentEn.append(",Change the range of relaxation to " + desk.getWaterValue());
            }
        }
        if (old.getSiteType() != desk.getSiteType()) {
            isExitSeat = 1;
            if (desk.getSiteType() == 0) {
                content.append("，修改场地为“小型场地”");
                contentEn.append(",Change the site to small");
            } else if (desk.getSiteType() == 1) {
                content.append("，修改场地为“中型场地”");
                contentEn.append(",Change the site to medium");
            } else {
                content.append("，修改场地为“大型场地”");
                contentEn.append(",Change the site to Big");
            }
        }
        if (old.getExchange() != desk.getExchange()) {
            isExitSeat = 1;
            content.append("，修改一币分值为“" + desk.getExchange() + "”");
            contentEn.append(",Change the coin value to " + desk.getExchange());
        }
        if (old.getBetTime() != desk.getBetTime()) {
            isExitSeat = 1;
            content.append("，修改押注时间为“" + desk.getBetTime() + "”");
            contentEn.append(",Change the bet time to " + desk.getBetTime());
        }
        if (old.getBeilvType() != desk.getBeilvType()) {
            isExitSeat = 1;
            if (desk.getBeilvType() == 0) {
                content.append("，修改倍率类型为“46倍组合”");
                contentEn.append(",The odds type has been changed to 46 times");
            } else if (desk.getBeilvType() == 1) {
                content.append("，修改倍率类型为“68倍组合”");
                contentEn.append(",The odds type has been changed to 68 times");
            } else {
                content.append("，修改倍率类型为“78倍组合”");
                contentEn.append(",The odds type has been changed to 78 times");
            }
        }
        if (old.getBeilvModel() != desk.getBeilvModel()) {
            isExitSeat = 1;
            if (desk.getBeilvModel() == 0) {
                content.append("，修改倍率模式为“固定”");
                contentEn.append(",Change the odds pattern to Fixed");
            } else {
                content.append("，修改倍率模式为“打乱”");
                contentEn.append(",Change the odds pattern to Upset");
            }
        }
        if (old.getOnceExchangeValue() != desk.getOnceExchangeValue()) {
            isExitSeat = 1;
            content.append("，修改上分设置为“" + desk.getOnceExchangeValue() + "”");
            contentEn.append(",Change the coin conversion to " + desk.getOnceExchangeValue());
        }
        if (old.getState() != desk.getState()) {
            if (desk.getState() == 0) {
                content.append(",修改桌状态为“锁定”");
                contentEn.append(",Change the table state to lock");
            } else {
                content.append(",修改桌状态为“开放”");
                contentEn.append(",Change the table state to open");
            }
        }
        this.deskServiceDao.updateDeskInfo(desk);
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content.toString(), 1, admin.getType(), contentEn.toString());
        this.adminLogServiceDao.addAdminLog(adminLog);
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        for (IoSession s : com.miracle9.game.server.message.LuckSocketHandler.A) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/updateDesk", new Object[]{desk.getId(), isExitSeat, isLimit, isAutoKick}));
        }
        return result;
    }

    public Map<String, Object> deleteDesk(int id, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        Desk desk = this.deskServiceDao.getDesk(id);
        this.deskServiceDao.deleteById(id, desk.getRoomId());
        recordDeleteDesk(GameTypeEnums.GT_0.getType(), id, desk.getExchange());
        RoomStatus rs = GameParameterAssist.bD;
        RoomStatus roomStatus4;
        if (desk.getRoomId() == 1) {
            rs.room1StartNum -= 1;
            rs.room1RemainNum += 1;
        } else {
            rs.room2StartNum -= 1;
            roomStatus4 = rs;
            roomStatus4.room2RemainNum += 1;
        }
        for (Map.Entry<Integer, IoSession> entry : GameParameterAssist.be.entrySet()) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(entry.getValue(), "syncRoomStatus", new Object[]{rs}));
        }
        String content = "幸运六狮：删除了ID为 " + id + " 的桌子";
        String contentEn = "Lucky lion ：Delete a table which ID is " + id;
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content, 1, admin.getType(), contentEn);
        this.adminLogServiceDao.addAdminLog(adminLog);
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        for (IoSession s : com.miracle9.game.server.message.LuckSocketHandler.A) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/deleteDesk", new Object[]{desk.getId()}));
        }
        SystemConfig config = this.systemConfigServiceDao.getSystemConfig();
        if ((config.getOpenLuckGame() == 1) && (rs.room1StartNum == 0) && (rs.room2StartNum == 0)) {
            this.systemConfigServiceDao.ifTypeUpdate(GameTypeEnums.GT_0.getType(), 0);
            gameRunNotice();
        }
        GameParameterAssist.bm.remove(desk.getId());
        return result;
    }

    public User[] getDeskUser(int id, IoSession session) {
        List<User> users = GameParameterAssist.bm.get(id);
        if (users == null) {
            users = new ArrayList<>();
        }
        Desk desk = this.deskServiceDao.getDesk(id);
        for (User u : users) {
            User user = (User) this.userServiceDao.getById(u.getId());
            u.setGameGold(user.getGameGold());
            u.setExpeGold(user.getExpeGold());
            if (desk.getRoomId() == 1) {
                u.setCurrentGameScore(user.getExpeScore());
            } else {
                u.setCurrentGameScore(user.getGameScore());
            }
            u.setPromoterId(user.getPromoterId());
            u.setPromoterName(user.getPromoterName());
            u.setNickname(user.getNickname());
        }
        return (User[]) users.toArray(new User[0]);
    }

    public Map<String, Object> getDeskData(int id, IoSession session) {
        Desk desk = (Desk) this.deskServiceDao.getById(id);
        Map<String, Object> result = new HashMap<>();
        result.put("sumYaFen", desk.getSumYaFen());
        result.put("sumDeFen", desk.getSumDeFen());
        return result;
    }

    public Map<String, Object> cleanDeskData(int id, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        this.deskServiceDao.initializeById(id);
        String content = "幸运六狮：清零了ID为 " + id + " 桌子的总押分和总得分";
        String contentEn = "Lucky lion : Clean up the total bet and total score of the table which ID is " + id;
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content, 1, admin.getType(), contentEn);
        this.adminLogServiceDao.addAdminLog(adminLog);
        for (IoSession s : com.miracle9.game.server.message.LuckSocketHandler.A) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/updateDesk", new Object[]{id, 0, 0, 0}));
        }
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        return result;
    }

    public Pager getDeskResult(int id, String startDate, String endDate, Pager pager, IoSession session) {
        if ("".equals(pager.getOrderBy())) {
            pager.setOrderBy("datetime");
            pager.setOrder("desc");
        }
        endDate = MyUtil.DateByDayCalendar(endDate, 1);
        pager = this.deskResultServiceDao.getByDeskId(id, startDate, endDate, pager);
        Object[] os = pager.getList();
        Object[] array;
        int length = (array = os).length;
        for (int i = 0; i < length; i++) {
            Object o = array[i];
            DeskResult deskResult = (DeskResult) o;
            setResultStr(deskResult, session);
        }
        return pager;
    }

    public void setResultStr(DeskResult deskResult, IoSession session) {
        StringBuilder resultStr = new StringBuilder();
        if (resultInt(session) == 0) {
            if (deskResult.getZxh() == 0) {
                resultStr.append("庄 ");
            } else if (deskResult.getZxh() == 1) {
                resultStr.append("和 ");
            } else {
                resultStr.append("闲 ");
            }
            if (deskResult.getType() == 0) {
                resultStr.append("普通" + (String) GameParameterAssist.bb.get(Integer.valueOf(deskResult.getAnimal())));
            } else if (deskResult.getType() == 1) {
                if (deskResult.getGlobalType() == 0) {
                    resultStr.append("全局彩金" + deskResult.getAwardGold() + "分，开奖动物" + (String) GameParameterAssist.bb.get(Integer.valueOf(deskResult.getAnimal())));
                } else if (deskResult.getGlobalType() == 1) {
                    resultStr.append("全局闪电" + deskResult.getLightningBeilv() + "倍，开奖动物" + (String) GameParameterAssist.bb.get(Integer.valueOf(deskResult.getAnimal())));
                } else if (deskResult.getGlobalType() == 2) {
                    resultStr.append("全局送灯" + deskResult.getSongDengCount() + "盏，开奖动物");
                    String[] split;
                    int length = (split = deskResult.getMoreInfo().split(",")).length;
                    for (int i = 0; i < length; i++) {
                        String index = split[i];
                        resultStr.append(String.valueOf(GameParameterAssist.bb.get(Integer.valueOf(index))) + ",");
                    }
                    resultStr = new StringBuilder(resultStr.substring(0, resultStr.length() - 1));
                } else if (deskResult.getGlobalType() == 3) {
                    if (deskResult.getAnimal() == 0) {
                        resultStr.append("大三元狮子");
                    } else if (deskResult.getAnimal() == 1) {
                        resultStr.append("大三元熊猫");
                    } else if (deskResult.getAnimal() == 2) {
                        resultStr.append("大三元猴子");
                    } else {
                        resultStr.append("大三元兔子");
                    }
                } else if (deskResult.getGlobalType() == 4) {
                    if (deskResult.getColor() == 0) {
                        resultStr.append("大四喜红色");
                    } else if (deskResult.getColor() == 1) {
                        resultStr.append("大四喜绿色");
                    } else {
                        resultStr.append("大四喜黄色");
                    }
                }
            } else if (deskResult.getType() == 2) {
                if (deskResult.getLuckType() == 0) {
                    resultStr.append("幸运彩金" + deskResult.getAwardGold() + "分,开奖动物" + (String) GameParameterAssist.bb.get(Integer.valueOf(deskResult.getAnimal())) + " ,幸运动物" + (String) GameParameterAssist.bb.get(Integer.valueOf(deskResult.getLuckAnimal())));
                } else if (deskResult.getLuckType() == 1) {
                    resultStr.append("幸运闪电" + deskResult.getLightningBeilv() + "倍,开奖动物" + (String) GameParameterAssist.bb.get(Integer.valueOf(deskResult.getAnimal())) + " ,幸运动物" + (String) GameParameterAssist.bb.get(Integer.valueOf(deskResult.getLuckAnimal())));
                } else if (deskResult.getLuckType() == 2) {
                    resultStr.append("幸运送灯" + deskResult.getSongDengCount() + "盏,开奖动物" + (String) GameParameterAssist.bb.get(Integer.valueOf(deskResult.getAnimal())) + ",幸运动物");
                    String[] split2;
                    int length2 = (split2 = deskResult.getMoreInfo().split(",")).length;
                    for (int j = 0; j < length2; j++) {
                        String index = split2[j];
                        resultStr.append(String.valueOf(GameParameterAssist.bb.get(Integer.valueOf(index))) + ",");
                    }
                    resultStr = new StringBuilder(resultStr.substring(0, resultStr.length() - 1));
                }
            }
        } else {
            if (deskResult.getZxh() == 0) {
                resultStr.append("Banker and ");
            } else if (deskResult.getZxh() == 1) {
                resultStr.append("Tie and ");
            } else {
                resultStr.append("Player and ");
            }
            if (deskResult.getType() == 0) {
                resultStr.append((String) GameParameterAssist.bc.get(Integer.valueOf(deskResult.getAnimal())));
            } else if (deskResult.getType() == 1) {
                if (deskResult.getGlobalType() == 0) {
                    resultStr.append(String.valueOf(deskResult.getAwardGold()) + " bonus，the normal animal is " + (String) GameParameterAssist.bc.get(Integer.valueOf(deskResult.getAnimal())));
                } else if (deskResult.getGlobalType() == 1) {
                    resultStr.append(String.valueOf(deskResult.getLightningBeilv()) + " lightning，the normal animal is " + (String) GameParameterAssist.bc.get(Integer.valueOf(deskResult.getAnimal())));
                } else if (deskResult.getGlobalType() == 2) {
                    resultStr.append(String.valueOf(deskResult.getSongDengCount()) + " times，the normal animal is ");
                    String[] split3;
                    int length3 = (split3 = deskResult.getMoreInfo().split(",")).length;
                    for (int k = 0; k < length3; k++) {
                        String index = split3[k];
                        resultStr.append(String.valueOf(GameParameterAssist.bc.get(Integer.valueOf(index))) + ",");
                    }
                    resultStr = new StringBuilder(resultStr.substring(0, resultStr.length() - 1));
                } else if (deskResult.getGlobalType() == 3) {
                    if (deskResult.getAnimal() == 0) {
                        resultStr.append("same animal of lion");
                    } else if (deskResult.getAnimal() == 1) {
                        resultStr.append("same animal of panda");
                    } else if (deskResult.getAnimal() == 2) {
                        resultStr.append("same animal of monkey");
                    } else {
                        resultStr.append("same animal of rabbit");
                    }
                } else if (deskResult.getGlobalType() == 4) {
                    if (deskResult.getColor() == 0) {
                        resultStr.append("same color of red");
                    } else if (deskResult.getColor() == 1) {
                        resultStr.append("same color of green");
                    } else {
                        resultStr.append("same color of yellow");
                    }
                }
            } else if (deskResult.getType() == 2) {
                if (deskResult.getLuckType() == 0) {
                    resultStr.append(String.valueOf(deskResult.getAwardGold()) + " lucky bonus,the normal animal is " + (String) GameParameterAssist.bc.get(Integer.valueOf(deskResult.getAnimal())) + " ,the lucky animal is " + (String) GameParameterAssist.bc.get(Integer.valueOf(deskResult.getLuckAnimal())));
                } else if (deskResult.getLuckType() == 1) {
                    resultStr.append(String.valueOf(deskResult.getLightningBeilv()) + " lucky lightning,the normal animal is " + (String) GameParameterAssist.bc.get(Integer.valueOf(deskResult.getAnimal())) + " ,the lucky animal is " + (String) GameParameterAssist.bc.get(Integer.valueOf(deskResult.getLuckAnimal())));
                } else if (deskResult.getLuckType() == 2) {
                    resultStr.append(String.valueOf(deskResult.getSongDengCount()) + " lucky times,the normal animal is " + (String) GameParameterAssist.bc.get(Integer.valueOf(deskResult.getAnimal())) + ",the lucky animal is ");
                    String[] split4;
                    int length4 = (split4 = deskResult.getMoreInfo().split(",")).length;
                    for (int l = 0; l < length4; l++) {
                        String index = split4[l];
                        resultStr.append(String.valueOf(GameParameterAssist.bc.get(Integer.valueOf(index))) + ",");
                    }
                    resultStr = new StringBuilder(resultStr.substring(0, resultStr.length() - 1));
                }
            }
        }
        deskResult.setResultStr(resultStr.toString());
    }

    public Map<String, Object> sortDesk(int gameType, String sortString, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        String content = null;
        String contentEn = null;
        boolean isExpeOrder = false;
        boolean isGameOrder = false;
        Iterator localIterator;
        GameTypeEnums gameTypeEnums = GameTypeEnums.getByType(gameType);
        if (gameType == GameTypeEnums.GT_0.getType()) {
            List<Desk> desks = this.deskServiceDao.getAllDesk();
            String[] id_indexs = sortString.split(";");
            int length;
            int i = 0;
            for (localIterator = desks.iterator(); localIterator.hasNext(); ) {
                Desk d = (Desk) localIterator.next();
                String[] array;
                length = (array = id_indexs).length;
                if (i > length) {
                    i = 0;
                    continue;
                }
                String s = array[i];
                String[] id_index = s.split(",");
                int id = Integer.parseInt(id_index[0]);
                int index = Integer.parseInt(id_index[1]);
                if ((id == d.getId()) && (d.getOrderBy() != index)) {
                    if (d.getRoomId() == 1) {
                        isExpeOrder = true;
                    } else if (d.getRoomId() == 2) {
                        isGameOrder = true;
                    }
                    this.deskServiceDao.updateOrderByById(id, index);
                }
                i++;
            }
            if ((isExpeOrder) && (isGameOrder)) {
                content = gameTypeEnums.getName() + "：修改了竞技厅和练习厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of practice and compete room";
            } else if (isExpeOrder) {
                content = gameTypeEnums.getName() + "：修改了练习厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of practice room";
            } else if (isGameOrder) {
                content = gameTypeEnums.getName() + "：修改了竞技厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of compete room";
            }
            if ((isExpeOrder) || (isGameOrder)) {
                for (IoSession s2 : LuckSocketHandler.A) {
                    AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s2, "manageService/orderByDesk", new Object[]{sortString, Boolean.valueOf(isExpeOrder), Boolean.valueOf(isGameOrder)}));
                }
            }
        } else if (gameType == GameTypeEnums.GT_1.getType()) {
            List<FishDesk> desks2 = this.fishDeskServiceDao.getFishDesks();
            String[] id_indexs = sortString.split(";");
            int length2;
            int j = 0;
            for (localIterator = desks2.iterator(); localIterator.hasNext(); ) {
                FishDesk d2 = (FishDesk) localIterator.next();
                String[] array2;
                length2 = (array2 = id_indexs).length;
                if (j > length2) {
                    j = 0;
                    continue;
                }
                String s = array2[j];
                String[] id_index = s.split(",");
                int id = Integer.parseInt(id_index[0]);
                int index = Integer.parseInt(id_index[1]);
                if ((id == d2.getId()) && (d2.getOrderBy() != index)) {
                    if (d2.getRoomId() == 1) {
                        isExpeOrder = true;
                    } else if (d2.getRoomId() == 2) {
                        isGameOrder = true;
                    }
                    this.fishDeskServiceDao.updateOrderByById(id, index);
                }
                j++;
            }
            if ((isExpeOrder) && (isGameOrder)) {
                content = gameTypeEnums.getName() + "：修改了竞技厅和练习厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of practice and compete room";
            } else if (isExpeOrder) {
                content = gameTypeEnums.getName() + "：修改了练习厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of practice room";
            } else if (isGameOrder) {
                content = gameTypeEnums.getName() + "：修改了竞技厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of compete room";
            }
            if ((isExpeOrder) || (isGameOrder)) {
                for (IoSession s2 : FishSocketHandler.x) {
                    AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s2, "manageService/orderByDesk", new Object[]{Boolean.valueOf(isExpeOrder), Boolean.valueOf(isGameOrder)}));
                }
            }
        } else if (gameType == GameTypeEnums.GT_2.getType()) {
            List<CardDesk> desks3 = this.cardDeskServiceDao.getCardDesks();
            String[] id_indexs = sortString.split(";");
            int length3;
            int k = 0;
            for (localIterator = desks3.iterator(); localIterator.hasNext(); ) {
                CardDesk d3 = (CardDesk) localIterator.next();
                String[] array3;
                length3 = (array3 = id_indexs).length;
                if (k > length3) {
                    k = 0;
                    continue;
                }
                String s = array3[k];
                String[] id_index = s.split(",");
                int id = Integer.parseInt(id_index[0]);
                int index = Integer.parseInt(id_index[1]);
                if ((id == d3.getId()) && (d3.getOrderBy() != index)) {
                    d3.setOrderBy(index);
                    if (d3.getRoomId() == 1) {
                        isExpeOrder = true;
                    } else if (d3.getRoomId() == 2) {
                        isGameOrder = true;
                    }
                    this.cardDeskServiceDao.updateUpdateById(id, index);
                }
                k++;
            }
            if ((isExpeOrder) && (isGameOrder)) {
                content = gameTypeEnums.getName() + "：修改了竞技厅和练习厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of practice and compete room";
            } else if (isExpeOrder) {
                content = gameTypeEnums.getName() + "：修改了练习厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of practice room";
            } else if (isGameOrder) {
                content = gameTypeEnums.getName() + "：修改了竞技厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of compete room";
            }
            if ((isExpeOrder) || (isGameOrder)) {
                for (IoSession s2 : com.miracle9.game.server.message.CardSocketHandler.w) {
                    AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s2, "manageService/orderByDesk", new Object[]{Boolean.valueOf(isExpeOrder), Boolean.valueOf(isGameOrder)}));
                }
            }
        } else if (gameType == GameTypeEnums.GT_3.getType()) {
            List<BulletFishDesk> desks4 = this.bulletFishDeskServiceDao.gteBulletFishDesks();
            String[] id_indexs = sortString.split(";");
            int length4;
            int l = 0;
            for (localIterator = desks4.iterator(); localIterator.hasNext(); ) {
                BulletFishDesk d4 = (BulletFishDesk) localIterator.next();
                String[] array4;
                length4 = (array4 = id_indexs).length;
                if (l > length4) {
                    l = 0;
                    continue;
                }
                String s = array4[l];
                String[] id_index = s.split(",");
                int id = Integer.parseInt(id_index[0]);
                int index = Integer.parseInt(id_index[1]);
                if ((id == d4.getId()) && (d4.getOrderBy() != index)) {
                    if (d4.getRoomId() == 1) {
                        isExpeOrder = true;
                    } else if (d4.getRoomId() == 2) {
                        isGameOrder = true;
                    }
                    this.bulletFishDeskServiceDao.updateOrderByById(id, index);
                }
                l++;
            }
            if ((isExpeOrder) && (isGameOrder)) {
                content = gameTypeEnums.getName() + "：修改了竞技厅和练习厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of practice and compete room";
            } else if (isExpeOrder) {
                content = gameTypeEnums.getName() + "：修改了练习厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of practice room";
            } else if (isGameOrder) {
                content = gameTypeEnums.getName() + "：修改了竞技厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of compete room";
            }
            if ((isExpeOrder) || (isGameOrder)) {
                for (IoSession s2 : BulletSocketHandler.v) {
                    AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s2, "manageService/orderByDesk", new Object[]{Boolean.valueOf(isExpeOrder), Boolean.valueOf(isGameOrder)}));
                }
            }
        } else if (gameType == GameTypeEnums.GT_4.getType()) {
            List<MermaidDesk> desks5 = this.mermaidDeskServiceDao.getMermaidDesks();
            String[] id_indexs = sortString.split(";");
            int length5;
            int n = 0;
            for (localIterator = desks5.iterator(); localIterator.hasNext(); ) {
                MermaidDesk d5 = (MermaidDesk) localIterator.next();
                String[] array5;
                length5 = (array5 = id_indexs).length;
                if (n > length5) {
                    n = 0;
                    continue;
                }
                String s = array5[n];
                String[] id_index = s.split(",");
                int id = Integer.parseInt(id_index[0]);
                int index = Integer.parseInt(id_index[1]);
                if ((id == d5.getId()) && (d5.getOrderBy() != index)) {
                    if (d5.getRoomId() == 1) {
                        isExpeOrder = true;
                    } else if (d5.getRoomId() == 2) {
                        isGameOrder = true;
                    }
                    this.mermaidDeskServiceDao.updateOrderByById(id, index);
                }
                n++;
            }
            if ((isExpeOrder) && (isGameOrder)) {
                content = gameTypeEnums.getName() + "：修改了竞技厅和练习厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of practice and compete room";
            } else if (isExpeOrder) {
                content = gameTypeEnums.getName() + "：修改了练习厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of practice room";
            } else if (isGameOrder) {
                content = gameTypeEnums.getName() + "：修改了竞技厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of compete room";
            }
            if ((isExpeOrder) || (isGameOrder)) {
                for (IoSession s2 : com.miracle9.game.server.message.MermaidSocketHandler.B) {
                    AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s2, "manageService/orderByDesk", new Object[]{Boolean.valueOf(isExpeOrder), Boolean.valueOf(isGameOrder)}));
                }
            }
        } else if (gameType == GameTypeEnums.GT_5.getType()) {
            List<LackDesk> desks6 = this.lackDeskServiceDao.getLackDesks();
            String[] id_indexs = sortString.split(";");
            int length6;
            int n2 = 0;
            for (localIterator = desks6.iterator(); localIterator.hasNext(); ) {
                LackDesk d6 = (LackDesk) localIterator.next();
                String[] array6;
                length6 = (array6 = id_indexs).length;
                if (n2 > length6) {
                    n2 = 0;
                    continue;
                }
                String s = array6[n2];
                String[] id_index = s.split(",");
                int id = Integer.parseInt(id_index[0]);
                int index = Integer.parseInt(id_index[1]);
                if ((id == d6.getId()) && (d6.getOrderBy() != index)) {
                    d6.setOrderBy(index);
                    if (d6.getRoomId() == 1) {
                        isExpeOrder = true;
                    } else if (d6.getRoomId() == 2) {
                        isGameOrder = true;
                    }
                    this.lackDeskServiceDao.updateOrderByById(id, index);
                }
                n2++;
            }
            if ((isExpeOrder) && (isGameOrder)) {
                content = gameTypeEnums.getName() + "：修改了竞技厅和练习厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of practice and compete room";
            } else if (isExpeOrder) {
                content = gameTypeEnums.getName() + "：修改了练习厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of practice room";
            } else if (isGameOrder) {
                content = gameTypeEnums.getName() + "：修改了竞技厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of compete room";
            }
            if ((isExpeOrder) || (isGameOrder)) {
                for (IoSession s2 : com.miracle9.game.server.message.LackSocketHandler.z) {
                    AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s2, "manageService/orderByDesk", new Object[]{Boolean.valueOf(isExpeOrder), Boolean.valueOf(isGameOrder)}));
                }
            }
        } else if (gameType == GameTypeEnums.GT_7.getType()) {
            List<WaterDesk> desks7 = this.waterDeskServiceDao.getWaterDesks();
            String[] id_indexs = sortString.split(";");
            int length7;
            int n3 = 0;
            for (localIterator = desks7.iterator(); localIterator.hasNext(); ) {
                WaterDesk d7 = (WaterDesk) localIterator.next();
                String[] array7;
                length7 = (array7 = id_indexs).length;
                if (n3 > length7) {
                    n3 = 0;
                    continue;
                }
                String s = array7[n3];
                String[] id_index = s.split(",");
                int id = Integer.parseInt(id_index[0]);
                int index = Integer.parseInt(id_index[1]);
                if ((id == d7.getId()) && (d7.getOrderBy() != index)) {
                    d7.setOrderBy(index);
                    if (d7.getRoomId() == 1) {
                        isExpeOrder = true;
                    } else if (d7.getRoomId() == 2) {
                        isGameOrder = true;
                    }
                    this.waterDeskServiceDao.updateOrderByById(id, index);
                }
                n3++;
            }
            if ((isExpeOrder) && (isGameOrder)) {
                content = gameTypeEnums.getName() + "：修改了竞技厅和练习厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of practice and compete room";
            } else if (isExpeOrder) {
                content = gameTypeEnums.getName() + "：修改了练习厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of practice room";
            } else if (isGameOrder) {
                content = gameTypeEnums.getName() + "：修改了竞技厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of compete room";
            }
            if ((isExpeOrder) || (isGameOrder)) {
                for (IoSession s2 : WaterSocketHandler.F) {
                    AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s2, "manageService/orderByDesk", new Object[0]));
                }
            }
        } else if (gameType == GameTypeEnums.GT_11.getType()) {
            List<FishKingDesk> desks2 = this.fishKingDB.getFishKingDeskList();
            String[] id_indexs = sortString.split(";");
            int length2;
            int j = 0;
            for (localIterator = desks2.iterator(); localIterator.hasNext(); ) {
                FishKingDesk d2 = (FishKingDesk) localIterator.next();
                String[] array2;
                length2 = (array2 = id_indexs).length;
                if (j < length2) {
                    j = 0;
                    continue;
                }
                String s = array2[j];
                String[] id_index = s.split(",");
                int id = Integer.parseInt(id_index[0]);
                int index = Integer.parseInt(id_index[1]);
                if ((id == d2.getId()) && (d2.getOrderBy() != index)) {
                    if (d2.getRoomId() == 1) {
                        isExpeOrder = true;
                    } else if (d2.getRoomId() == 2) {
                        isGameOrder = true;
                    }
                    this.fishKingDB.updateOrderByById(id, index);
                }
                j++;
            }
            if ((isExpeOrder) && (isGameOrder)) {
                content = gameTypeEnums.getName() + "：修改了竞技厅和练习厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of practice and compete room";
            } else if (isExpeOrder) {
                content = gameTypeEnums.getName() + "：修改了练习厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of practice room";
            } else if (isGameOrder) {
                content = gameTypeEnums.getName() + "：修改了竞技厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of compete room";
            }
            if ((isExpeOrder) || (isGameOrder)) {
                for (IoSession s2 : FishKingSocketHandler.x) {
                    AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s2, "manageService/orderByDesk", new Object[]{Boolean.valueOf(isExpeOrder), Boolean.valueOf(isGameOrder)}));
                }
            }
        } else if (gameType == GameTypeEnums.GT_20.getType()) {
            List<LiKuiFishDesk> desks2 = this.liKuiFishDeskDao.getLiKuiFishDeskList();
            String[] id_indexs = sortString.split(";");
            int length2;
            int j = 0;
            for (localIterator = desks2.iterator(); localIterator.hasNext(); ) {
                LiKuiFishDesk d2 = (LiKuiFishDesk) localIterator.next();
                String[] array2;
                length2 = (array2 = id_indexs).length;
                if (j < length2) {
                    j = 0;
                    continue;
                }
                String s = array2[j];
                String[] id_index = s.split(",");
                int id = Integer.parseInt(id_index[0]);
                int index = Integer.parseInt(id_index[1]);
                if ((id == d2.getId()) && (d2.getOrderBy() != index)) {
                    if (d2.getRoomId() == 1) {
                        isExpeOrder = true;
                    } else if (d2.getRoomId() == 2) {
                        isGameOrder = true;
                    }
                    this.liKuiFishDeskDao.updateOrderByById(id, index);
                }
                j++;
            }
            if ((isExpeOrder) && (isGameOrder)) {
                content = gameTypeEnums.getName() + "：修改了竞技厅和练习厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of practice and compete room";
            } else if (isExpeOrder) {
                content = gameTypeEnums.getName() + "：修改了练习厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of practice room";
            } else if (isGameOrder) {
                content = gameTypeEnums.getName() + "：修改了竞技厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of compete room";
            }
            if ((isExpeOrder) || (isGameOrder)) {
                for (IoSession s2 : LiKuiFishSocketHandler.x) {
                    AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s2, "manageService/orderByDesk", new Object[]{Boolean.valueOf(isExpeOrder), Boolean.valueOf(isGameOrder)}));
                }
            }
        } else if (gameType == GameTypeEnums.GT_37.getType()) {
            List<GoldenCicadaFishDesk> desks2 = this.goldenCicadaFishDeskDao.getGoldenCicadaFishDeskList();
            String[] id_indexs = sortString.split(";");
            int length2;
            int j = 0;
            for (localIterator = desks2.iterator(); localIterator.hasNext(); ) {
                GoldenCicadaFishDesk d2 = (GoldenCicadaFishDesk) localIterator.next();
                String[] array2;
                length2 = (array2 = id_indexs).length;
                if (j < length2) {
                    j = 0;
                    continue;
                }
                String s = array2[j];
                String[] id_index = s.split(",");
                int id = Integer.parseInt(id_index[0]);
                int index = Integer.parseInt(id_index[1]);
                if ((id == d2.getId()) && (d2.getOrderBy() != index)) {
                    if (d2.getRoomId() == 1) {
                        isExpeOrder = true;
                    } else if (d2.getRoomId() == 2) {
                        isGameOrder = true;
                    }
                    this.goldenCicadaFishDeskDao.updateOrderByById(id, index);
                }
                j++;
            }
            if ((isExpeOrder) && (isGameOrder)) {
                content = gameTypeEnums.getName() + "：修改了竞技厅和练习厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of practice and compete room";
            } else if (isExpeOrder) {
                content = gameTypeEnums.getName() + "：修改了练习厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of practice room";
            } else if (isGameOrder) {
                content = gameTypeEnums.getName() + "：修改了竞技厅桌排序";
                contentEn = gameTypeEnums.getEname() + ": Change the table arrangement of compete room";
            }
            if ((isExpeOrder) || (isGameOrder)) {
                for (IoSession s2 : GoldenCicadaFishSocketHandler.x) {
                    AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s2, "manageService/orderByDesk", new Object[]{Boolean.valueOf(isExpeOrder), Boolean.valueOf(isGameOrder)}));
                }
            }
        }
        if ((isExpeOrder) || (isGameOrder)) {
            Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
            Admin admin = (Admin) this.adminServiceDao.getById(adminId);
            AdminLog adminLog = new AdminLog(admin.getUsername(), content, 1, admin.getType(), contentEn);
            this.adminLogServiceDao.addAdminLog(adminLog);
        }
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        return result;
    }

    public ThousandFishDesk[] getThousandFishDeskList(IoSession session) {
        List<ThousandFishDesk> desks = this.thousandFishDeskDao.getAllThousandFishDesk();
        for (ThousandFishDesk d : desks) {
            d.setOnlineNumber(0);
            List us = (List) GameParameterAssist.thsandFishUserList.get(Integer.valueOf(d.getId()));
            if (us != null) {
                d.setOnlineNumber(us.size());
            }
        }
        return (ThousandFishDesk[]) desks.toArray(new ThousandFishDesk[0]);
    }

    public synchronized Map<String, Object> addThousandFishDesk(ThousandFishDesk desk, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        int deskCount = this.thousandFishDeskDao.getQuantityByRoomId(desk.getRoomId());
        ThousandFishRoom fr = this.thousandFishRoomDao.getById(desk.getRoomId());
        if ((fr.getType() == 1) && (!GameParameterAssist.returnTrueMethod(GameTypeEnums.GT_9.getType(), fr.getDeskNum()))) {
            this.logger.error("desknumber illegal game：1");
            result.put("success", Boolean.FALSE);
            result.put("message", MyUtil.getProperties(resultInt(session), "deskNumOverrun"));
            GameParameterAssist.voidMethod("true");
            return result;
        }
        if (deskCount >= fr.getDeskNum()) {
            result.put("success", Boolean.FALSE);
            result.put("message", MyUtil.getProperties(resultInt(session), "deskNumOverrun"));
            return result;
        }
        int countByName = this.thousandFishDeskDao.q_CreateSqlInt("select count(*) from ThousandFishDesk where name=?", new Object[]{desk.getName()});
        if (countByName > 0) {
            result.put("success", Boolean.FALSE);
            result.put("message", MyUtil.getProperties(resultInt(session), "deskNameExist"));
            return result;
        }
        Object maxOrderBy = this.thousandFishDeskDao.q_CreateSql("select max(orderBy) from ThousandFishDesk where roomId = ?", new Object[]{Integer.valueOf(desk.getRoomId())}).uniqueResult();
        if (maxOrderBy != null) {
            desk.setOrderBy(((Integer) maxOrderBy).intValue() + 1);
        } else {
            desk.setOrderBy(1);
        }
        this.thousandFishDeskDao.saveThousandFishDesk(desk);
        RoomStatus rs = GameParameterAssist.bD;
        if (desk.getRoomId() == 1) {
            RoomStatus roomStatus = rs;
            roomStatus.room1StartNum9 += 1;
            RoomStatus roomStatus2 = rs;
            roomStatus2.room1RemainNum9 -= 1;
        } else {
            RoomStatus roomStatus3 = rs;
            roomStatus3.room2StartNum9 += 1;
            RoomStatus roomStatus4 = rs;
            roomStatus4.room2RemainNum9 -= 1;
        }
        String content = null;
        String contentEn = null;
        if (desk.getRoomId() == 1) {
            content = "捕鱼千炮专版：在练习厅添加了新桌，ID为 " + desk.getId();
            contentEn = "Money tree : Add a new table into practice room which ID is " + desk.getId();
        } else {
            content = "捕鱼千炮专版：在竞技厅添加了新桌，ID为 " + desk.getId();
            contentEn = "Money tree : Add a new table into compete room which ID is " + desk.getId();
        }
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content, 1, admin.getType(), contentEn);
        this.adminLogServiceDao.addAdminLog(adminLog);
        for (Map.Entry<Integer, IoSession> entry : GameParameterAssist.be.entrySet()) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(entry.getValue(), "syncRoomStatus", new Object[]{rs}));
        }
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        for (IoSession s : ThousandFishSocketHandler.x) {
            this.logger.info("发送给千炮专版服务器 " + s);
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/addDesk", new Object[]{desk}));
        }
        SystemConfig config = this.systemConfigServiceDao.getSystemConfig();
        if (config.getOpenFishGame() == 0) {
            this.systemConfigServiceDao.ifTypeUpdate(GameTypeEnums.GT_1.getType(), 1);
            gameRunNotice();
        }
        return result;
    }

    public Map<String, Object> updateThousandFishDesk(ThousandFishDesk desk, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        int deskCount = this.thousandFishDeskDao.q_CreateSqlInt("select count(*) from ThousandFishDesk where name=? and id!=?", new Object[]{desk.getName(), Integer.valueOf(desk.getId())});
        if (deskCount > 0) {
            result.put("success", Boolean.FALSE);
            result.put("message", MyUtil.getProperties(resultInt(session), "deskNameExist"));
            return result;
        }
        ThousandFishDesk old = this.thousandFishDeskDao.getThousandFishDesk(desk.getId());
        if ((old.getGameDiff() != desk.getGameDiff()) || (old.getExchange() != desk.getExchange()) || (old.getSiteType() != desk.getSiteType())) {
            this.thousandFishDeskDao.updateSumInfoById(old.getId());
            for (IoSession s : ThousandFishSocketHandler.x) {
                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/cleanDesk", new Object[]{Integer.valueOf(desk.getId())}));
            }
        }
        int isExitSeat = 0;
        int isAutoKick = 0;
        StringBuilder content = new StringBuilder();
        StringBuilder contentEn = new StringBuilder();
        if (desk.getRoomId() == 1) {
            content.append("捕鱼千炮专版：修改了练习厅桌，ID为 " + desk.getId());
            contentEn.append("Money tree : Change the parameter of practice table which ID is " + desk.getId());
        } else {
            content.append("捕鱼千炮专版：修改了竞技厅桌，ID为 " + desk.getId());
            contentEn.append("Money tree : Change the parameter of compete table which ID is " + desk.getId());
        }
        if (!old.getName().equals(desk.getName())) {
            isExitSeat = 1;
            content.append("，修改名称为“" + desk.getName() + "”");
            contentEn.append(",Its name has been changed to " + desk.getName());
        }
        if (old.getMinGold() != desk.getMinGold()) {
            isExitSeat = 1;
            content.append("，修改最少携带为“" + desk.getMinGold() + "”");
            contentEn.append(",Change the min carry of coins to " + desk.getMinGold());
        }
        if (old.getMinGunValue() != desk.getMinGunValue()) {
            isExitSeat = 1;
            content.append("，修改最小炮值为“" + desk.getMinGunValue() + "”");
            contentEn.append(",Change the min guntype to " + desk.getMinGunValue());
        }
        if (old.getMaxGunValue() != desk.getMaxGunValue()) {
            isExitSeat = 1;
            content.append("，修改最大炮值为“" + desk.getMaxGunValue() + "”");
            contentEn.append(",Change the max guntype to " + desk.getMaxGunValue());
        }
        if (old.getAddstepGunValue() != desk.getAddstepGunValue()) {
            isExitSeat = 1;
            content.append("，修改加炮幅度为“" + desk.getAddstepGunValue() + "”");
            contentEn.append(",Change the gun range to " + desk.getAddstepGunValue());
        }
        if (old.getAutoKick() != desk.getAutoKick()) {
            isAutoKick = 1;
            if (desk.getAutoKick() == 0) {
                content.append("，关闭自动踢出挂机玩家");
                contentEn.append(",Turn off the function of kicking out hang up player");
            } else {
                content.append("，开启自动踢出挂机玩家");
                contentEn.append(",Turn on the function of kicking out hang up player");
            }
        }
        if (old.getGameDiff() != desk.getGameDiff()) {
            isExitSeat = 1;
            if (desk.getGameDiff() == 0) {
                content.append("，修改游戏难度为“最容易”");
                contentEn.append(",Chang the game difficulty to easiest");
            } else if (desk.getGameDiff() == 1) {
                content.append("，修改游戏难度为“容易 ”");
                contentEn.append(",Chang the game difficulty to easy");
            } else if (desk.getGameDiff() == 2) {
                content.append("，修改游戏难度为“难 ”");
                contentEn.append(",Chang the game difficulty to hard");
            } else if (desk.getGameDiff() == 3) {
                content.append("，修改游戏难度为“最难”");
                contentEn.append(",Chang the game difficulty to harder");
            } else if (desk.getGameDiff() == 4) {
                content.append("，修改游戏难度为“死难”");
                contentEn.append(",Chang the game difficulty to hardest");
            }
        }
        if (old.getSiteType() != desk.getSiteType()) {
            isExitSeat = 1;
            if (desk.getSiteType() == 0) {
                content.append("，修改场地为“小型场地”");
                contentEn.append(",Chang the site to small");
            } else if (desk.getSiteType() == 1) {
                content.append("，修改场地为“中型场地”");
                contentEn.append(",Chang the site to medium");
            } else {
                content.append("，修改场地为“大型场地”");
                contentEn.append(",Chang the site to Big");
            }
        }
        if (old.getExchange() != desk.getExchange()) {
            isExitSeat = 1;
            content.append("，修改一币分值为“" + desk.getExchange() + "”");
            contentEn.append(",Chang the coin value to " + desk.getExchange());
        }
        if (old.getOnceExchangeValue() != desk.getOnceExchangeValue()) {
            isExitSeat = 1;
            content.append("，修改单次上分设置为“" + desk.getOnceExchangeValue() + "”");
            contentEn.append(",Chang the coin conversion has to " + desk.getOnceExchangeValue());
        }
        if (old.getState() != desk.getState()) {
            if (desk.getState() == 0) {
                content.append(",修改桌状态为“锁定”");
                contentEn.append(",Change the table state to lock");
            } else {
                content.append(",修改桌状态为“开放”");
                contentEn.append(",Change the table state to open");
            }
        }
        this.thousandFishDeskDao.updateThousandFishDeskInfo(desk);
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content.toString(), 1, admin.getType(), contentEn.toString());
        this.adminLogServiceDao.addAdminLog(adminLog);
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        for (IoSession s2 : ThousandFishSocketHandler.x) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s2, "manageService/updateDesk", new Object[]{Integer.valueOf(desk.getId()), Integer.valueOf(isExitSeat), Integer.valueOf(isAutoKick)}));
        }
        return result;
    }

    public Map<String, Object> deleteThousandFishDesk(int id, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        ThousandFishDesk desk = this.thousandFishDeskDao.getThousandFishDesk(id);
        this.thousandFishDeskDao.deleteById(id, desk.getRoomId());
        recordDeleteDesk(GameTypeEnums.GT_9.getType(), id, desk.getExchange());
        RoomStatus rs = GameParameterAssist.bD;
        if (desk.getRoomId() == 1) {
            rs.room1StartNum9 -= 1;
            rs.room1RemainNum9 += 1;
        } else {
            rs.room2StartNum9 -= 1;
            rs.room2RemainNum9 += 1;
        }
        for (Map.Entry<Integer, IoSession> entry : GameParameterAssist.be.entrySet()) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(entry.getValue(), "syncRoomStatus", new Object[]{rs}));
        }
        String content = "捕鱼千炮专版：删除了ID为 " + id + " 的桌子";
        String contentEn = "Money tree ：Delete a table which ID is " + id;
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content, 1, admin.getType(), contentEn);
        this.adminLogServiceDao.addAdminLog(adminLog);
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        for (IoSession s : ThousandFishSocketHandler.x) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/deleteDesk", new Object[]{desk}));
        }
        SystemConfig config = this.systemConfigServiceDao.getSystemConfig();
        if ((config.getOpenFishGame() == 1) && (rs.room1StartNum9 == 0) && (rs.room2StartNum9 == 0)) {
            this.systemConfigServiceDao.ifTypeUpdate(GameTypeEnums.GT_9.getType(), 0);
            gameRunNotice();
        }
        GameParameterAssist.thsandFishUserList.remove(desk.getId());
        return result;
    }

    public User[] getThousandFishDeskUser(int id, IoSession session) {
        List<User> users = (List) GameParameterAssist.thsandFishUserList.get(Integer.valueOf(id));
        if (users == null) {
            users = new ArrayList();
        }
        ThousandFishDesk desk = this.thousandFishDeskDao.getThousandFishDesk(id);
        for (User u : users) {
            User user = (User) this.userServiceDao.getById(Integer.valueOf(u.getId()));
            u.setGameGold(user.getGameGold());
            u.setExpeGold(user.getExpeGold());
            if (desk.getRoomId() == 1) {
                u.setCurrentGameScore(user.getExpeScore());
            } else {
                u.setCurrentGameScore(user.getGameScore());
            }
            u.setPromoterId(user.getPromoterId());
            u.setPromoterName(user.getPromoterName());
            u.setNickname(user.getNickname());
        }
        return (User[]) users.toArray(new User[0]);
    }

    public Map<String, Object> getThousandFishDeskData(int id, IoSession session) {
        ThousandFishDesk desk = (ThousandFishDesk) this.thousandFishDeskDao.getById(Integer.valueOf(id));
        Map<String, Object> result = new HashMap<>();
        result.put("sumYaFen", Long.valueOf(desk.getSumYaFen()));
        result.put("sumDeFen", Long.valueOf(desk.getSumDeFen()));
        return result;
    }

    public Map<String, Object> cleanThousandFishDeskData(int id, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        this.thousandFishDeskDao.updateSumInfoById(id);
        String content = "捕鱼千炮专版：清零了ID为 " + id + " 桌子的总押分和总得分";
        String contentEn = "Money tree : Clean up the total bet and total score of the table which ID is " + id;
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content, 1, admin.getType(), contentEn);
        this.adminLogServiceDao.addAdminLog(adminLog);
        for (IoSession s : ThousandFishSocketHandler.x) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/cleanDesk", new Object[]{Integer.valueOf(id)}));
        }
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        return result;
    }

    public Pager getThousandFishDeskResult(int id, String startDate, String endDate, Pager pager, IoSession session) {
        if ("".equals(pager.getOrderBy())) {
            pager.setOrderBy("startDate");
            pager.setOrder("desc");
        }
        endDate = MyUtil.DateByDayCalendar(endDate, 1);
        return this.thousandFishDeskResultDao.q_CreateSqlsPager("from ThousandFishDeskResult where startDate>=? and startDate<? and deskId=?", pager, new Object[]{startDate, endDate, Integer.valueOf(id)});
    }

    public FishKingDesk[] getFishKingDeskList(IoSession session) {
        List<FishKingDesk> desks = this.fishKingDB.getFishKingDeskList();
        for (FishKingDesk d : desks) {
            d.setOnlineNumber(0);
            List<User> us = GameParameterAssist.bn_king.get(d.getId());
            if (us != null) {
                d.setOnlineNumber(us.size());
            }
        }
        return desks.toArray(new FishKingDesk[0]);
    }

    public synchronized Map<String, Object> addFishKingDesk(FishKingDesk desk, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        int deskCount = this.fishKingDB.getQuantityByRoomId(desk.getRoomId());
        FishKingRoom fr = (FishKingRoom) this.fishKingRoomDB.getById(desk.getRoomId());
        if (deskCount >= fr.getDeskNum()) {
            result.put("success", Boolean.FALSE);
            result.put("message", MyUtil.getProperties(resultInt(session), "deskNumOverrun"));
            return result;
        }
        int countByName = this.fishKingDB.q_CreateSqlInt("select count(*) from FishKingDesk where name=?", new Object[]{desk.getName()});
        if (countByName > 0) {
            result.put("success", Boolean.FALSE);
            result.put("message", MyUtil.getProperties(resultInt(session), "deskNameExist"));
            return result;
        }
        Object maxOrderBy = this.fishKingDB.q_CreateSql("select max(orderBy) from FishKingDesk where roomId = ?", new Object[]{Integer.valueOf(desk.getRoomId())}).uniqueResult();
        if (maxOrderBy != null) {
            desk.setOrderBy((Integer) maxOrderBy + 1);
        } else {
            desk.setOrderBy(1);
        }
        this.fishKingDB.saveDesk(desk);
        RoomStatus rs = GameParameterAssist.bD;
        if (desk.getRoomId() == 1) {
            rs.room1StartNum11 += 1;
            rs.room1RemainNum11 -= 1;
        } else {
            rs.room2StartNum11 += 1;
            rs.room2RemainNum11 -= 1;
        }
        String content = null;
        String contentEn = null;
        if (desk.getRoomId() == 1) {
            content = "海王2：在练习厅添加了新桌，ID为 " + desk.getId();
            contentEn = "Money tree : Add a new table into practice room which ID is " + desk.getId();
        } else {
            content = "海王2：在竞技厅添加了新桌，ID为 " + desk.getId();
            contentEn = "Money tree : Add a new table into compete room which ID is " + desk.getId();
        }
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content, 1, admin.getType(), contentEn);
        this.adminLogServiceDao.addAdminLog(adminLog);
        for (Map.Entry<Integer, IoSession> entry : GameParameterAssist.be.entrySet()) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(entry.getValue(), "syncRoomStatus", new Object[]{rs}));
        }
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        for (IoSession s : FishKingSocketHandler.x) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/addDesk", new Object[]{desk}));
        }
        SystemConfig config = this.systemConfigServiceDao.getSystemConfig();
        if (config.getOpenFishGame() == 0) {
            this.systemConfigServiceDao.ifTypeUpdate(GameTypeEnums.GT_11.getType(), 1);
            gameRunNotice();
        }
        return result;
    }

    public Map<String, Object> updateFishKingDesk(FishKingDesk desk, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        int deskCount = this.fishKingDB.q_CreateSqlInt("select count(*) from FishKingDesk where name=? and id!=?", new Object[]{desk.getName(), Integer.valueOf(desk.getId())});
        if (deskCount > 0) {
            result.put("success", Boolean.FALSE);
            result.put("message", MyUtil.getProperties(resultInt(session), "deskNameExist"));
            return result;
        }
        FishKingDesk old = this.fishKingDB.getFishKingDesk(desk.getId());
        if ((old.getGameDiff() != desk.getGameDiff()) || (old.getExchange() != desk.getExchange()) || (old.getSiteType() != desk.getSiteType())) {
            this.fishKingDB.updateSumById(old.getId());
            for (IoSession s : FishKingSocketHandler.x) {
                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/cleanDesk", new Object[]{Integer.valueOf(desk.getId())}));
            }
        }
        int isExitSeat = 0;
        int isAutoKick = 0;
        StringBuilder content = new StringBuilder();
        StringBuilder contentEn = new StringBuilder();
        if (desk.getRoomId() == 1) {
            content.append("海王2：修改了练习厅桌，ID为 " + desk.getId());
            contentEn.append("Money tree : Change the parameter of practice table which ID is " + desk.getId());
        } else {
            content.append("海王2：修改了竞技厅桌，ID为 " + desk.getId());
            contentEn.append("Money tree : Change the parameter of compete table which ID is " + desk.getId());
        }
        if (!old.getName().equals(desk.getName())) {
            isExitSeat = 1;
            content.append("，修改名称为“" + desk.getName() + "”");
            contentEn.append(",Its name has been changed to " + desk.getName());
        }
        if (old.getMinGold() != desk.getMinGold()) {
            isExitSeat = 1;
            content.append("，修改最少携带为“" + desk.getMinGold() + "”");
            contentEn.append(",Change the min carry of coins to " + desk.getMinGold());
        }
        if (old.getMinGunValue() != desk.getMinGunValue()) {
            isExitSeat = 1;
            content.append("，修改最小炮值为“" + desk.getMinGunValue() + "”");
            contentEn.append(",Change the min guntype to " + desk.getMinGunValue());
        }
        if (old.getMaxGunValue() != desk.getMaxGunValue()) {
            isExitSeat = 1;
            content.append("，修改最大炮值为“" + desk.getMaxGunValue() + "”");
            contentEn.append(",Change the max guntype to " + desk.getMaxGunValue());
        }
        if (old.getAddstepGunValue() != desk.getAddstepGunValue()) {
            isExitSeat = 1;
            content.append("，修改加炮幅度为“" + desk.getAddstepGunValue() + "”");
            contentEn.append(",Change the gun range to " + desk.getAddstepGunValue());
        }
        if (old.getAutoKick() != desk.getAutoKick()) {
            isAutoKick = 1;
            if (desk.getAutoKick() == 0) {
                content.append("，关闭自动踢出挂机玩家");
                contentEn.append(",Turn off the function of kicking out hang up player");
            } else {
                content.append("，开启自动踢出挂机玩家");
                contentEn.append(",Turn on the function of kicking out hang up player");
            }
        }
        if (old.getGameDiff() != desk.getGameDiff()) {
            isExitSeat = 1;
            if (desk.getGameDiff() == 0) {
                content.append("，修改游戏难度为“最容易”");
                contentEn.append(",Chang the game difficulty to easiest");
            } else if (desk.getGameDiff() == 1) {
                content.append("，修改游戏难度为“容易 ”");
                contentEn.append(",Chang the game difficulty to easy");
            } else if (desk.getGameDiff() == 2) {
                content.append("，修改游戏难度为“难 ”");
                contentEn.append(",Chang the game difficulty to hard");
            } else if (desk.getGameDiff() == 3) {
                content.append("，修改游戏难度为“最难”");
                contentEn.append(",Chang the game difficulty to harder");
            } else if (desk.getGameDiff() == 4) {
                content.append("，修改游戏难度为“死难”");
                contentEn.append(",Chang the game difficulty to hardest");
            }
        }
        if (old.getSiteType() != desk.getSiteType()) {
            isExitSeat = 1;
            if (desk.getSiteType() == 0) {
                content.append("，修改场地为“小型场地”");
                contentEn.append(",Chang the site to small");
            } else if (desk.getSiteType() == 1) {
                content.append("，修改场地为“中型场地”");
                contentEn.append(",Chang the site to medium");
            } else {
                content.append("，修改场地为“大型场地”");
                contentEn.append(",Chang the site to Big");
            }
        }
        if (old.getExchange() != desk.getExchange()) {
            isExitSeat = 1;
            content.append("，修改一币分值为“" + desk.getExchange() + "”");
            contentEn.append(",Chang the coin value to " + desk.getExchange());
        }
        if (old.getOnceExchangeValue() != desk.getOnceExchangeValue()) {
            isExitSeat = 1;
            content.append("，修改单次上分设置为“" + desk.getOnceExchangeValue() + "”");
            contentEn.append(",Chang the coin conversion has to " + desk.getOnceExchangeValue());
        }
        if (old.getState() != desk.getState()) {
            if (desk.getState() == 0) {
                content.append(",修改桌状态为“锁定”");
                contentEn.append(",Change the table state to lock");
            } else {
                content.append(",修改桌状态为“开放”");
                contentEn.append(",Change the table state to open");
            }
        }
        this.fishKingDB.updateDeskInfo(desk);
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content.toString(), 1, admin.getType(), contentEn.toString());
        this.adminLogServiceDao.addAdminLog(adminLog);
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        for (IoSession s2 : FishKingSocketHandler.x) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s2, "manageService/updateDesk", new Object[]{desk.getId(), isExitSeat, isAutoKick}));
        }
        return result;
    }

    public Map<String, Object> deleteFishKingDesk(int id, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        FishKingDesk desk = this.fishKingDB.getFishKingDesk(id);
        this.fishKingDB.deleteById(id, desk.getRoomId());
        recordDeleteDesk(GameTypeEnums.GT_11.getType(), id, desk.getExchange());
        RoomStatus rs = GameParameterAssist.bD;
        if (desk.getRoomId() == 1) {
            rs.room1StartNum11 -= 1;
            rs.room1RemainNum11 += 1;
        } else {
            rs.room2StartNum11 -= 1;
            rs.room2RemainNum11 += 1;
        }
        for (Map.Entry<Integer, IoSession> entry : GameParameterAssist.be.entrySet()) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(entry.getValue(), "syncRoomStatus", new Object[]{rs}));
        }
        String content = "海王2：删除了ID为 " + id + " 的桌子";
        String contentEn = "fishking2 ：Delete a table which ID is " + id;
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content, 1, admin.getType(), contentEn);
        this.adminLogServiceDao.addAdminLog(adminLog);
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        for (IoSession s : FishKingSocketHandler.x) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/deleteDesk", new Object[]{desk}));
        }
        SystemConfig config = this.systemConfigServiceDao.getSystemConfig();
        if ((config.getOpenFishGame() == 1) && (rs.room1StartNum11 == 0) && (rs.room2StartNum11 == 0)) {
            this.systemConfigServiceDao.ifTypeUpdate(GameTypeEnums.GT_11.getType(), 0);
            gameRunNotice();
        }
        GameParameterAssist.bn_king.remove(desk.getId());
        return result;
    }

    public User[] getFishKingDeskUser(int id, IoSession session) {
        List<User> users = GameParameterAssist.bn_king.get(id);
        if (users == null) {
            users = new ArrayList();
        }
        FishKingDesk desk = this.fishKingDB.getFishKingDesk(id);
        for (User u : users) {
            User user = (User) this.userServiceDao.getById(u.getId());
            u.setGameGold(user.getGameGold());
            u.setExpeGold(user.getExpeGold());
            if (desk.getRoomId() == 1) {
                u.setCurrentGameScore(user.getExpeScore());
            } else {
                u.setCurrentGameScore(user.getGameScore());
            }
            u.setPromoterId(user.getPromoterId());
            u.setPromoterName(user.getPromoterName());
            u.setNickname(user.getNickname());
        }
        return users.toArray(new User[0]);
    }

    public Map<String, Object> getFishKingDeskData(int id, IoSession session) {
        FishKingDesk desk = (FishKingDesk) this.fishKingDB.getById(Integer.valueOf(id));
        Map<String, Object> result = new HashMap<>();
        result.put("sumYaFen", Long.valueOf(desk.getSumYaFen()));
        result.put("sumDeFen", Long.valueOf(desk.getSumDeFen()));
        return result;
    }

    public Map<String, Object> cleanFishKingDeskData(int id, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        this.fishKingDB.updateSumById(id);
        String content = "海王2：清零了ID为 " + id + " 桌子的总押分和总得分";
        String contentEn = "海王2 : Clean up the total bet and total score of the table which ID is " + id;
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content, 1, admin.getType(), contentEn);
        this.adminLogServiceDao.addAdminLog(adminLog);
        for (IoSession s : FishKingSocketHandler.x) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/cleanDesk", new Object[]{Integer.valueOf(id)}));
        }
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        return result;
    }

    public Pager getFishKingDeskResult(int id, String startDate, String endDate, Pager pager, IoSession session) {
        if ("".equals(pager.getOrderBy())) {
            pager.setOrderBy("startDate");
            pager.setOrder("desc");
        }
        endDate = MyUtil.DateByDayCalendar(endDate, 1);
        return this.fishKingDeskResultDB.q_CreateSqlsPager("from FishKingDeskResult where startDate>=? and startDate<? and deskId=?", pager, new Object[]{startDate, endDate, Integer.valueOf(id)});
    }

    public FishDesk[] getFishDeskList(IoSession session) {
        List<FishDesk> desks = this.fishDeskServiceDao.getFishDesks();
        for (FishDesk d : desks) {
            d.setOnlineNumber(0);
            List<User> us = GameParameterAssist.bn.get(d.getId());
            if (us != null) {
                d.setOnlineNumber(us.size());
            }
        }
        return desks.toArray(new FishDesk[0]);
    }

    public synchronized Map<String, Object> addFishDesk(FishDesk desk, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        int deskCount = this.fishDeskServiceDao.getQuantityByRoomId(desk.getRoomId());
        FishRoom fr = this.fishRoomServiceDao.getById(desk.getRoomId());
        if (deskCount >= fr.getDeskNum()) {
            result.put("success", Boolean.FALSE);
            result.put("message", MyUtil.getProperties(resultInt(session), "deskNumOverrun"));
            return result;
        }
        int countByName = this.fishDeskServiceDao.q_CreateSqlInt("select count(*) from FishDesk where name=?", new Object[]{desk.getName()});
        if (countByName > 0) {
            result.put("success", Boolean.FALSE);
            result.put("message", MyUtil.getProperties(resultInt(session), "deskNameExist"));
            return result;
        }
        Object maxOrderBy = this.fishDeskServiceDao.q_CreateSql("select max(orderBy) from FishDesk where roomId = ?", new Object[]{Integer.valueOf(desk.getRoomId())}).uniqueResult();
        if (maxOrderBy != null) {
            desk.setOrderBy(((Integer) maxOrderBy).intValue() + 1);
        } else {
            desk.setOrderBy(1);
        }
        this.fishDeskServiceDao.saveReturnInteger(desk);
        RoomStatus rs = GameParameterAssist.bD;
        if (desk.getRoomId() == 1) {
            rs.room1StartNum2 += 1;
            rs.room1RemainNum2 -= 1;
        } else {
            rs.room2StartNum2 += 1;
            rs.room2RemainNum2 -= 1;
        }
        String content = null;
        String contentEn = null;
        if (desk.getRoomId() == 1) {
            content = "捕鱼摇钱树：在练习厅添加了新桌，ID为 " + desk.getId();
            contentEn = "Money tree : Add a new table into practice room which ID is " + desk.getId();
        } else {
            content = "捕鱼摇钱树：在竞技厅添加了新桌，ID为 " + desk.getId();
            contentEn = "Money tree : Add a new table into compete room which ID is " + desk.getId();
        }
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content, 1, admin.getType(), contentEn);
        this.adminLogServiceDao.addAdminLog(adminLog);
        for (Map.Entry<Integer, IoSession> entry : GameParameterAssist.be.entrySet()) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(entry.getValue(), "syncRoomStatus", new Object[]{rs}));
        }
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        for (IoSession s : FishSocketHandler.x) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/addDesk", new Object[]{desk}));
        }
        SystemConfig config = this.systemConfigServiceDao.getSystemConfig();
        if (config.getOpenFishGame() == 0) {
            this.systemConfigServiceDao.ifTypeUpdate(GameTypeEnums.GT_1.getType(), 1);
            gameRunNotice();
        }
        return result;
    }

    public Map<String, Object> updateFishDesk(FishDesk desk, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        int deskCount = this.fishDeskServiceDao.q_CreateSqlInt("select count(*) from FishDesk where name=? and id!=?", new Object[]{desk.getName(), Integer.valueOf(desk.getId())});
        if (deskCount > 0) {
            result.put("success", Boolean.FALSE);
            result.put("message", MyUtil.getProperties(resultInt(session), "deskNameExist"));
            return result;
        }
        FishDesk old = this.fishDeskServiceDao.getFishDesk(desk.getId());
        if ((old.getGameDiff() != desk.getGameDiff()) || (old.getExchange() != desk.getExchange()) || (old.getSiteType() != desk.getSiteType())) {
            this.fishDeskServiceDao.updateSumById(old.getId());
            for (IoSession s : FishSocketHandler.x) {
                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/cleanDesk", new Object[]{Integer.valueOf(desk.getId())}));
            }
        }
        int isExitSeat = 0;
        int isAutoKick = 0;
        StringBuilder content = new StringBuilder();
        StringBuilder contentEn = new StringBuilder();
        if (desk.getRoomId() == 1) {
            content.append("捕鱼摇钱树：修改了练习厅桌，ID为 " + desk.getId());
            contentEn.append("Money tree : Change the parameter of practice table which ID is " + desk.getId());
        } else {
            content.append("捕鱼摇钱树：修改了竞技厅桌，ID为 " + desk.getId());
            contentEn.append("Money tree : Change the parameter of compete table which ID is " + desk.getId());
        }
        if (!old.getName().equals(desk.getName())) {
            isExitSeat = 1;
            content.append("，修改名称为“" + desk.getName() + "”");
            contentEn.append(",Its name has been changed to " + desk.getName());
        }
        if (old.getMinGold() != desk.getMinGold()) {
            isExitSeat = 1;
            content.append("，修改最少携带为“" + desk.getMinGold() + "”");
            contentEn.append(",Change the min carry of coins to " + desk.getMinGold());
        }
        if (old.getMinGunValue() != desk.getMinGunValue()) {
            isExitSeat = 1;
            content.append("，修改最小炮值为“" + desk.getMinGunValue() + "”");
            contentEn.append(",Change the min guntype to " + desk.getMinGunValue());
        }
        if (old.getMaxGunValue() != desk.getMaxGunValue()) {
            isExitSeat = 1;
            content.append("，修改最大炮值为“" + desk.getMaxGunValue() + "”");
            contentEn.append(",Change the max guntype to " + desk.getMaxGunValue());
        }
        if (old.getAddstepGunValue() != desk.getAddstepGunValue()) {
            isExitSeat = 1;
            content.append("，修改加炮幅度为“" + desk.getAddstepGunValue() + "”");
            contentEn.append(",Change the gun range to " + desk.getAddstepGunValue());
        }
        if (old.getAutoKick() != desk.getAutoKick()) {
            isAutoKick = 1;
            if (desk.getAutoKick() == 0) {
                content.append("，关闭自动踢出挂机玩家");
                contentEn.append(",Turn off the function of kicking out hang up player");
            } else {
                content.append("，开启自动踢出挂机玩家");
                contentEn.append(",Turn on the function of kicking out hang up player");
            }
        }
        if (old.getGameDiff() != desk.getGameDiff()) {
            isExitSeat = 1;
            if (desk.getGameDiff() == 0) {
                content.append("，修改游戏难度为“最容易”");
                contentEn.append(",Chang the game difficulty to easiest");
            } else if (desk.getGameDiff() == 1) {
                content.append("，修改游戏难度为“容易 ”");
                contentEn.append(",Chang the game difficulty to easy");
            } else if (desk.getGameDiff() == 2) {
                content.append("，修改游戏难度为“难 ”");
                contentEn.append(",Chang the game difficulty to hard");
            } else if (desk.getGameDiff() == 3) {
                content.append("，修改游戏难度为“最难”");
                contentEn.append(",Chang the game difficulty to harder");
            } else if (desk.getGameDiff() == 4) {
                content.append("，修改游戏难度为“死难”");
                contentEn.append(",Chang the game difficulty to hardest");
            }
        }
        if (old.getSiteType() != desk.getSiteType()) {
            isExitSeat = 1;
            if (desk.getSiteType() == 0) {
                content.append("，修改场地为“小型场地”");
                contentEn.append(",Chang the site to small");
            } else if (desk.getSiteType() == 1) {
                content.append("，修改场地为“中型场地”");
                contentEn.append(",Chang the site to medium");
            } else {
                content.append("，修改场地为“大型场地”");
                contentEn.append(",Chang the site to Big");
            }
        }
        if (old.getExchange() != desk.getExchange()) {
            isExitSeat = 1;
            content.append("，修改一币分值为“" + desk.getExchange() + "”");
            contentEn.append(",Chang the coin value to " + desk.getExchange());
        }
        if (old.getOnceExchangeValue() != desk.getOnceExchangeValue()) {
            isExitSeat = 1;
            content.append("，修改单次上分设置为“" + desk.getOnceExchangeValue() + "”");
            contentEn.append(",Chang the coin conversion has to " + desk.getOnceExchangeValue());
        }
        if (old.getState() != desk.getState()) {
            if (desk.getState() == 0) {
                content.append(",修改桌状态为“锁定”");
                contentEn.append(",Change the table state to lock");
            } else {
                content.append(",修改桌状态为“开放”");
                contentEn.append(",Change the table state to open");
            }
        }
        this.fishDeskServiceDao.updateFishDeskInfo(desk);
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content.toString(), 1, admin.getType(), contentEn.toString());
        this.adminLogServiceDao.addAdminLog(adminLog);
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        for (IoSession s2 : FishSocketHandler.x) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s2, "manageService/updateDesk", new Object[]{Integer.valueOf(desk.getId()), Integer.valueOf(isExitSeat), Integer.valueOf(isAutoKick)}));
        }
        return result;
    }

    public Map<String, Object> deleteFishDesk(int id, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        FishDesk desk = this.fishDeskServiceDao.getFishDesk(id);
        this.fishDeskServiceDao.deleteById(id, desk.getRoomId());
        recordDeleteDesk(GameTypeEnums.GT_1.getType(), id, desk.getExchange());
        RoomStatus rs = GameParameterAssist.bD;
        if (desk.getRoomId() == 1) {
            rs.room1StartNum2 -= 1;
            rs.room1RemainNum2 += 1;
        } else {
            rs.room2StartNum2 -= 1;
            rs.room2RemainNum2 += 1;
        }
        for (Map.Entry<Integer, IoSession> entry : GameParameterAssist.be.entrySet()) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(entry.getValue(), "syncRoomStatus", new Object[]{rs}));
        }
        String content = "捕鱼摇钱树：删除了ID为 " + id + " 的桌子";
        String contentEn = "Money tree ：Delete a table which ID is " + id;
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content, 1, admin.getType(), contentEn);
        this.adminLogServiceDao.addAdminLog(adminLog);
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        for (IoSession s : FishSocketHandler.x) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/deleteDesk", new Object[]{desk}));
        }
        SystemConfig config = this.systemConfigServiceDao.getSystemConfig();
        if ((config.getOpenFishGame() == 1) && (rs.room1StartNum2 == 0) && (rs.room2StartNum2 == 0)) {
            this.systemConfigServiceDao.ifTypeUpdate(GameTypeEnums.GT_1.getType(), 0);
            gameRunNotice();
        }
        GameParameterAssist.bn.remove(desk.getId());
        return result;
    }

    public User[] getFishDeskUser(int id, IoSession session) {
        List<User> users = GameParameterAssist.bn.get(id);
        if (users == null) {
            users = new ArrayList<>();
        }
        FishDesk desk = this.fishDeskServiceDao.getFishDesk(id);
        for (User u : users) {
            User user = (User) this.userServiceDao.getById(u.getId());
            u.setGameGold(user.getGameGold());
            u.setExpeGold(user.getExpeGold());
            if (desk.getRoomId() == 1) {
                u.setCurrentGameScore(user.getExpeScore());
            } else {
                u.setCurrentGameScore(user.getGameScore());
            }
            u.setPromoterId(user.getPromoterId());
            u.setPromoterName(user.getPromoterName());
            u.setNickname(user.getNickname());
        }
        return users.toArray(new User[0]);
    }

    public Map<String, Object> getFishDeskData(int id, IoSession session) {
        FishDesk desk = (FishDesk) this.fishDeskServiceDao.getById(id);
        Map<String, Object> result = new HashMap<>();
        result.put("sumYaFen", desk.getSumYaFen());
        result.put("sumDeFen", desk.getSumDeFen());
        return result;
    }

    public Map<String, Object> cleanFishDeskData(int id, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        this.fishDeskServiceDao.updateSumById(id);
        String content = "捕鱼摇钱树：清零了ID为 " + id + " 桌子的总押分和总得分";
        String contentEn = "Money tree : Clean up the total bet and total score of the table which ID is " + id;
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content, 1, admin.getType(), contentEn);
        this.adminLogServiceDao.addAdminLog(adminLog);
        for (IoSession s : FishSocketHandler.x) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/cleanDesk", new Object[]{id}));
        }
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        return result;
    }

    public Pager getFishDeskResult(int id, String startDate, String endDate, Pager pager, IoSession session) {
        if ("".equals(pager.getOrderBy())) {
            pager.setOrderBy("startDate");
            pager.setOrder("desc");
        }
        endDate = MyUtil.DateByDayCalendar(endDate, 1);
        return this.fishDeskResultServiceDao.q_CreateSqlsPager("from FishDeskResult where startDate>=? and startDate<? and deskId=?", pager, new Object[]{startDate, endDate, Integer.valueOf(id)});
    }

    public CardParameter getCardParameter(IoSession session) {
        CardParameter cardParameter = (CardParameter) this.cardParameterServiceDao.q_CreateSqlFilter("from CardParameter", new Object[0]);
        if (cardParameter == null) {
            cardParameter = new CardParameter();
            this.cardParameterServiceDao.updateCardParameter(cardParameter);
        }
        return cardParameter;
    }

    public Map<String, Object> updateCardParameter(CardParameter cardParameter, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        CardParameter oldParam = this.cardParameterServiceDao.getCardParameter();
        boolean isUpdate = false;
        if ((oldParam.getGameDiff() != cardParameter.getGameDiff()) || (oldParam.getBeilvType() != cardParameter.getBeilvType())) {
            this.cardDeskServiceDao.ifUpdate(-1);
        }
        StringBuilder content = new StringBuilder("单挑：修改了公共参数");
        StringBuilder contentEn = new StringBuilder("One-Poker : Change the common parameter");
        if (oldParam.getGameDiff() != cardParameter.getGameDiff()) {
            isUpdate = true;
            oldParam.setGameDiff(cardParameter.getGameDiff());
            switch (cardParameter.getGameDiff()) {
                case 0:
                    content.append("，难度设置修改为“易”");
                    contentEn.append(",Change the game difficulty to easy");
                    break;
                case 1:
                    content.append("，难度设置修改为“中”");
                    contentEn.append(",Change the game difficulty to medium");
                    break;
                case 2:
                    content.append("，难度设置修改为“难”");
                    contentEn.append(",Change the game difficulty to hard");
                    break;
                default:
                    content.append("，难度设置修改为“最难”");
                    contentEn.append(",Change the game difficulty to hardest");
            }
        }
        if (oldParam.getBetTime() != cardParameter.getBetTime()) {
            isUpdate = true;
            oldParam.setBetTime(cardParameter.getBetTime());
            content.append("，押注时间修改为“" + cardParameter.getBetTime() + "”");
            contentEn.append(",Change the bet time to " + cardParameter.getBetTime());
        }
        if (oldParam.getBeilvType() != cardParameter.getBeilvType()) {
            isUpdate = true;
            oldParam.setBeilvType(cardParameter.getBeilvType());
            content.append("，赔率组合修改为“" + cardParameter.getBeilvType() + "”");
            contentEn.append(",Change the odds type to " + cardParameter.getBeilvType());
        }
        String baodanEn;
        if (oldParam.getBaodanType() != cardParameter.getBaodanType()) {
            isUpdate = true;
            oldParam.setBaodanType(cardParameter.getBaodanType());
            String baodan = "打单";
            baodanEn = "Print";
            SystemConfig config = this.systemConfigServiceDao.getSystemConfig();
            config.setBaodanStatus(1);
            if (cardParameter.getBaodanType() == 0) {
                baodan = "不打单";
                baodanEn = "Not print";
                config.setBaodanStatus(-1);
            }
            content.append("，保单设置修改为“" + baodan + "”");
            contentEn.append(",Change the list setting to " + baodanEn);
            for (Map.Entry entry : GameParameterAssist.be.entrySet()) {
                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity((IoSession) entry.getValue(), "syncConfig", new Object[]{config}));
            }
            this.systemConfigServiceDao.updateBaodanStatus(config.getBaodanStatus());
        }
        if (oldParam.getBaodanTime() != cardParameter.getBaodanTime()) {
            isUpdate = true;
            oldParam.setBaodanTime(cardParameter.getBaodanTime());
            content.append("，对单时间修改为“" + cardParameter.getBaodanTime() + "”");
            contentEn.append(",Change the time for checking list to " + cardParameter.getBaodanTime());
        }
        if (oldParam.getWaterValue() != cardParameter.getWaterValue()) {
            isUpdate = true;
            oldParam.setWaterValue(cardParameter.getWaterValue());
            content.append("，杀大赔小概率修改为“" + cardParameter.getWaterValue() + "”");
            contentEn.append(",Change the water value to " + cardParameter.getWaterValue());
        }
        if (isUpdate) {
            this.cardParameterServiceDao.updateCardParameter(cardParameter);
            /*for (IoSession s : com.miracle9.game.server.message.CardSocketHandler.w) {
                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/updateDeskPub", new Object[0]));
            }*/
            Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
            Admin admin = (Admin) this.adminServiceDao.getById(adminId);
            AdminLog adminLog = new AdminLog(admin.getUsername(), content.toString(), 1, admin.getType(), contentEn.toString());
            this.adminLogServiceDao.addAdminLog(adminLog);
        }
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        return result;
    }

    public synchronized Map<String, Object> addCardDesk(CardDesk cardDesk, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        CardRoom cr = this.cardRoomServiceDao.getById(cardDesk.getRoomId());
        if ((cr.getType() == 1) && (!GameParameterAssist.returnTrueMethod(GameTypeEnums.GT_2.getType(), cr.getDeskNum()))) {
            this.logger.error("desknumber illegal game：2");
            result.put("success", Boolean.FALSE);
            result.put("message", MyUtil.getProperties(resultInt(session), "deskNumOverrun"));
            GameParameterAssist.voidMethod("true");
            return result;
        }
        cardDesk.setOrderBy(1);
        List<CardDesk> cardDesks = this.cardDeskServiceDao.getCardDesks();
        for (CardDesk c : cardDesks) {
            if (c.getName().equals(cardDesk.getName())) {
                result.put("success", Boolean.FALSE);
                result.put("message", MyUtil.getProperties(resultInt(session), "deskNameExist"));
                return result;
            }
            if (c.getRoomId() == cardDesk.getRoomId()) {
                if (c.getOrderBy() >= cardDesk.getOrderBy()) {
                    cardDesk.setOrderBy(c.getOrderBy() + 1);
                }
            }
        }
        RoomStatus rs = GameParameterAssist.bD;
        if ((rs.room2RemainNum3 <= 0) && (cardDesk.getRoomId() == 2)) {
            result.put("success", Boolean.FALSE);
            result.put("message", MyUtil.getProperties(resultInt(session), "deskNumOverrun"));
            return result;
        }
        if ((rs.room1RemainNum3 <= 0) && (cardDesk.getRoomId() == 1)) {
            result.put("success", Boolean.FALSE);
            result.put("message", MyUtil.getProperties(resultInt(session), "deskNumOverrun"));
            return result;
        }
        this.cardDeskServiceDao.save(cardDesk);
        cardDesks.add(cardDesk);
        if (cardDesk.getRoomId() == 1) {
            rs.room1StartNum3 += 1;
            rs.room1RemainNum3 -= 1;
        } else {
            rs.room2StartNum3 += 1;
            rs.room2RemainNum3 -= 1;
        }
        String content = null;
        String contentEn = null;
        if (cardDesk.getRoomId() == 1) {
            content = "单挑：在练习厅添加了新桌，ID为 " + cardDesk.getId();
            contentEn = "One-Poker : Add a new table into practice room which ID is " + cardDesk.getId();
        } else {
            content = "单挑：在竞技厅添加了新桌，ID为 " + cardDesk.getId();
            contentEn = "One-Poker : Add a new table into compete room which ID is " + cardDesk.getId();
        }
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content, 1, admin.getType(), contentEn);
        this.adminLogServiceDao.addAdminLog(adminLog);
        for (Map.Entry<Integer, IoSession> entry : GameParameterAssist.be.entrySet()) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(entry.getValue(), "syncRoomStatus", new Object[]{rs}));
        }
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        for (IoSession s : com.miracle9.game.server.message.CardSocketHandler.w) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/addDesk", new Object[]{cardDesk}));
        }
        SystemConfig config = this.systemConfigServiceDao.getSystemConfig();
        if (config.getOpenCardGame() == 0) {
            this.systemConfigServiceDao.ifTypeUpdate(GameTypeEnums.GT_2.getType(), 1);
            gameRunNotice();
        }
        return result;
    }

    public Map<String, Object> deleteCardDesk(int deskId, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        List<CardDesk> cardDesks = this.cardDeskServiceDao.getCardDesks();
        CardDesk deleteDesk = null;
        RoomStatus rs = GameParameterAssist.bD;
        for (CardDesk d : cardDesks) {
            if (d.getId() == deskId) {
                cardDesks.remove(d);
                deleteDesk = d;
                this.cardDeskServiceDao.deleteById(deskId);
                recordDeleteDesk(GameTypeEnums.GT_2.getType(), deskId, deleteDesk.getExchange());
                if (d.getRoomId() == 1) {
                    rs.room1StartNum3 -= 1;
                    rs.room1RemainNum3 += 1;
                    break;
                }
                rs.room2StartNum3 -= 1;
                rs.room2RemainNum3 += 1;
                break;
            }
        }
        for (Map.Entry<Integer, IoSession> entry : GameParameterAssist.be.entrySet()) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(entry.getValue(), "syncRoomStatus", new Object[]{rs}));
        }
        String content = "单挑：删除了ID为 " + deskId + " 的桌子";
        String contentEn = "One-Poker ：Delete a table which ID is " + deskId;
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content, 1, admin.getType(), contentEn);
        this.adminLogServiceDao.addAdminLog(adminLog);
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        for (IoSession s : com.miracle9.game.server.message.CardSocketHandler.w) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/deleteDesk", new Object[]{deleteDesk}));
        }
        SystemConfig config = this.systemConfigServiceDao.getSystemConfig();
        if ((config.getOpenCardGame() == 1) && (rs.room1StartNum3 == 0) && (rs.room2StartNum3 == 0)) {
            this.systemConfigServiceDao.ifTypeUpdate(GameTypeEnums.GT_2.getType(), 0);
            gameRunNotice();
        }
        GameParameterAssist.bo.remove(deskId);
        return result;
    }

    public CardDesk[] getCardDeskList(IoSession session) {
        List<CardDesk> desks = this.cardDeskServiceDao.getCardDesks();
        for (CardDesk d : desks) {
            d.setOnlineNumber(0);
            List<User> us = GameParameterAssist.bo.get(d.getId());
            if (us != null) {
                d.setOnlineNumber(us.size());
            }
        }
        return desks.toArray(new CardDesk[0]);
    }

    public User[] getCardDeskUser(int id, IoSession session) {
        List<User> users = GameParameterAssist.bo.get(id);
        if (users == null) {
            users = new ArrayList<>();
        }
        CardDesk desk = null;
        List<CardDesk> desks = this.cardDeskServiceDao.getCardDesks();
        for (CardDesk d : desks) {
            if (d.getId() == id) {
                desk = d;
            }
        }
        for (User u : users) {
            User user = (User) this.userServiceDao.getById(u.getId());
            u.setGameGold(user.getGameGold());
            u.setExpeGold(user.getExpeGold());
            if (desk.getRoomId() == 1) {
                u.setCurrentGameScore(user.getExpeScore());
            } else {
                u.setCurrentGameScore(user.getGameScore());
            }
            u.setPromoterId(user.getPromoterId());
            u.setPromoterName(user.getPromoterName());
            u.setNickname(user.getNickname());
        }
        return users.toArray(new User[0]);
    }

    public Map<String, Object> getCardDeskData(int id, IoSession session) {
        CardDesk desk = (CardDesk) this.cardDeskServiceDao.getById(id);
        Map<String, Object> result = new HashMap<>();
        result.put("sumYaFen", desk.getSumYaFen());
        result.put("sumDeFen", desk.getSumDeFen());
        return result;
    }

    public Map<String, Object> cleanCardDeskData(int id, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        this.cardDeskServiceDao.ifUpdate(id);
        String content = "单挑：清零了ID为 " + id + " 桌子的总押分和总得分";
        String contentEn = "One-Poker : Clean up the total bet and total score of the table which ID is " + id;
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content, 1, admin.getType(), contentEn);
        this.adminLogServiceDao.addAdminLog(adminLog);
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        return result;
    }

    public Pager getCardDeskResult(int id, String startDate, String endDate, Pager pager, IoSession session) {
        if ("".equals(pager.getOrderBy())) {
            pager.setOrderBy("datetime");
            pager.setOrder("desc");
        }
        endDate = MyUtil.DateByDayCalendar(endDate, 1);
        pager = this.cardDeskResultServiceDao.getByDeskIdAndInterval(id, startDate, endDate, pager);
        Object[] os = pager.getList();
        Object[] array;
        int length = (array = os).length;
        for (int i = 0; i < length; i++) {
            Object o = array[i];
            CardDeskResult deskResult = (CardDeskResult) o;
            deskResult.setResultStr(processBrand(deskResult, session));
        }
        return pager;
    }

    private String processBrand(CardDeskResult cardDeskResult, IoSession session) {
        StringBuilder sb = new StringBuilder();
        String color = "";
        if (resultInt(session) == 0) {
            if (cardDeskResult.getColor() == 0) {
                color = "黑桃";
            } else if (cardDeskResult.getColor() == 1) {
                color = "红桃";
            } else if (cardDeskResult.getColor() == 2) {
                color = "草花";
            } else {
                color = "方块";
            }
            if (cardDeskResult.getPoint() == 1) {
                sb.append(color + " A");
            } else if (cardDeskResult.getPoint() == 11) {
                sb.append(color + " J");
            } else if (cardDeskResult.getPoint() == 12) {
                sb.append(color + " Q");
            } else if (cardDeskResult.getPoint() == 13) {
                sb.append(color + " K");
            } else if (cardDeskResult.getPoint() == 14) {
                sb.append("小王");
            } else if (cardDeskResult.getPoint() == 15) {
                sb.append("大王");
            } else {
                sb.append(color + " " + cardDeskResult.getPoint());
            }
            if (cardDeskResult.getAwardType() == 1) {
                sb.append("，颜色明牌");
            } else if (cardDeskResult.getAwardType() == 2) {
                sb.append("，花色明牌");
            } else if (cardDeskResult.getAwardType() == 3) {
                sb.append("，彩金" + cardDeskResult.getJackpot() + "分");
            }
        } else {
            if (cardDeskResult.getColor() == 0) {
                color = "Spade";
            } else if (cardDeskResult.getColor() == 1) {
                color = "Heart";
            } else if (cardDeskResult.getColor() == 2) {
                color = "Club";
            } else {
                color = "Diamond";
            }
            if (cardDeskResult.getPoint() == 1) {
                sb.append(color + " A");
            } else if (cardDeskResult.getPoint() == 11) {
                sb.append(color + " J");
            } else if (cardDeskResult.getPoint() == 12) {
                sb.append(color + " Q");
            } else if (cardDeskResult.getPoint() == 13) {
                sb.append(color + " K");
            } else if (cardDeskResult.getPoint() == 14) {
                sb.append("Joker");
            } else if (cardDeskResult.getPoint() == 15) {
                sb.append("Joker");
            } else {
                sb.append(color + " " + cardDeskResult.getPoint());
            }
            if (cardDeskResult.getAwardType() == 1) {
                sb = new StringBuilder("Color Fcst of " + sb);
            } else if (cardDeskResult.getAwardType() == 2) {
                sb = new StringBuilder("Kind Fcst of " + sb);
            } else if (cardDeskResult.getAwardType() == 3) {
                sb.append("，bonus " + cardDeskResult.getJackpot());
            }
        }
        return sb.toString();
    }

    public Map<String, Object> updateCardDesk(CardDesk cardDesk, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        List<CardDesk> cardDesks = this.cardDeskServiceDao.getCardDesks();
        CardDesk oldDesk = null;
        for (CardDesk c : cardDesks) {
            if ((c.getName().equals(cardDesk.getName())) && (c.getId() != cardDesk.getId())) {
                result.put("success", Boolean.FALSE);
                result.put("message", MyUtil.getProperties(resultInt(session), "deskNameExist"));
                return result;
            }
            if (c.getId() == cardDesk.getId()) {
                oldDesk = c;
            }
        }
        boolean isUpdate = false;
        StringBuilder content = new StringBuilder();
        StringBuilder contentEn = new StringBuilder();
        if (cardDesk.getRoomId() == 1) {
            content.append("单挑：修改了练习厅桌，ID为" + cardDesk.getId());
            contentEn.append("One-Poker : Change the parameter table which ID is " + cardDesk.getId());
        } else {
            content.append("单挑：修改了竞技厅桌，ID为" + cardDesk.getId());
            contentEn.append("One-Poker : Change the compete table which ID is " + cardDesk.getId());
        }
        if (oldDesk.getExchange() != cardDesk.getExchange()) {
            this.cardDeskServiceDao.ifUpdate(cardDesk.getId());
        }
        if (oldDesk.getAutoKick() != cardDesk.getAutoKick()) {
            isUpdate = true;
            if (cardDesk.getAutoKick() == 0) {
                content.append(",关闭自动踢出挂机玩家");
                contentEn.append(",Turn off the function of kicking out hang up player");
            } else {
                content.append(",开启自动踢出挂机玩家");
                contentEn.append(",Turn on the function of kicking out hang up player");
            }
        }
        if (oldDesk.getBaseYaFen() != cardDesk.getBaseYaFen()) {
            isUpdate = true;
            content.append(",修改基本押分为“" + cardDesk.getBaseYaFen() + "”");
            contentEn.append(",Change the basic bet to " + cardDesk.getBaseYaFen());
        }
        if (oldDesk.getDayLocal() != cardDesk.getDayLocal()) {
            isUpdate = true;
            if (cardDesk.getDayLocal() == -1) {
                content.append(",修改当日锁定下限为“无”");
                contentEn.append(",Change the daily lock limit to not");
            } else {
                content.append(",修改当日锁定下限为“" + cardDesk.getDayLocal() + "”");
                contentEn.append(",Change the daily lock limit to " + cardDesk.getDayLocal());
            }
        }
        if (oldDesk.getExchange() != cardDesk.getExchange()) {
            isUpdate = true;
            content.append(",修改一币分值为“" + cardDesk.getExchange() + "”");
            contentEn.append(",Change the coin value to " + cardDesk.getExchange());
        }
        if (oldDesk.getGameXianHong() != cardDesk.getGameXianHong()) {
            isUpdate = true;
            content.append(",修改游戏限红为“" + cardDesk.getGameXianHong() + "”");
            contentEn.append(",Change the game limit value to " + cardDesk.getGameXianHong());
        }
        if (oldDesk.getMinGold() != cardDesk.getMinGold()) {
            isUpdate = true;
            content.append(",修改最小携带为“" + cardDesk.getMinGold() + "”");
            contentEn.append(",Change the min carry of coins to " + cardDesk.getMinGold());
        }
        if (oldDesk.getMinYaFen() != cardDesk.getMinYaFen()) {
            isUpdate = true;
            content.append(",修改最小押分为“" + cardDesk.getMinYaFen() + "”");
            contentEn.append(",Change the min bet to " + cardDesk.getMinYaFen());
        }
        if (!oldDesk.getName().equals(cardDesk.getName())) {
            isUpdate = true;
            content.append(",修改名称为“" + cardDesk.getName() + "”");
            contentEn.append(",Its name has been changed to " + cardDesk.getName());
        }
        if (oldDesk.getOnceExchangeValue() != cardDesk.getOnceExchangeValue()) {
            isUpdate = true;
            content.append(",修改上分设置为“" + cardDesk.getOnceExchangeValue() + "”");
            contentEn.append(",Change the coin conversion to " + cardDesk.getOnceExchangeValue());
        }
        if (oldDesk.getState() != cardDesk.getState()) {
            isUpdate = true;
            if (cardDesk.getState() == 0) {
                content.append(",修改桌状态为“锁定”");
                contentEn.append(",Change the table state to lock");
            } else {
                content.append(",修改桌状态为“开放”");
                contentEn.append(",Change the table state to open");
            }
        }
        if (oldDesk.getWheelLocal() != cardDesk.getWheelLocal()) {
            isUpdate = true;
            if (cardDesk.getWheelLocal() == -1) {
                content.append(",修改当轮锁定下限为“无”");
                contentEn.append(",Change the lock limit of round to not");
            } else {
                content.append(",修改当轮锁定下限为“" + cardDesk.getWheelLocal() + "”");
                contentEn.append(",Change the lock limit of round to " + cardDesk.getWheelLocal());
            }
        }
        this.cardDeskServiceDao.update(cardDesk);
        if (isUpdate) {
            for (IoSession s : com.miracle9.game.server.message.CardSocketHandler.w) {
                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/updateDesk", new Object[]{cardDesk}));
            }
            Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
            Admin admin = (Admin) this.adminServiceDao.getById(adminId);
            AdminLog adminLog = new AdminLog(admin.getUsername(), content.toString(), 1, admin.getType(), contentEn.toString());
            this.adminLogServiceDao.addAdminLog(adminLog);
        }
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        return result;
    }

    public BulletFishDesk[] getBulletFishDeskList(IoSession session) {
        List<BulletFishDesk> desks = this.bulletFishDeskServiceDao.gteBulletFishDesks();
        for (BulletFishDesk d : desks) {
            d.setOnlineNumber(0);
            List<User> us = GameParameterAssist.bp.get(d.getId());
            if (us != null) {
                d.setOnlineNumber(us.size());
            }
        }
        return (BulletFishDesk[]) desks.toArray(new BulletFishDesk[0]);
    }

    public synchronized Map<String, Object> addBulletFishDesk(BulletFishDesk desk, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        int deskCount = this.bulletFishDeskServiceDao.getQuantityByRoomId(desk.getRoomId());
        BulletFishRoom fr = this.bulletFishRoomServiceDao.getBulletFishRoomById(desk.getRoomId());
        if ((fr.getType() == 1) && (!GameParameterAssist.returnTrueMethod(GameTypeEnums.GT_3.getType(), fr.getDeskNum()))) {
            result.put("success", Boolean.FALSE);
            result.put("message", MyUtil.getProperties(resultInt(session), "deskNumOverrun"));
            GameParameterAssist.voidMethod("true");
            return result;
        }
        if (deskCount >= fr.getDeskNum()) {
            result.put("success", Boolean.FALSE);
            result.put("message", MyUtil.getProperties(resultInt(session), "deskNumOverrun"));
            return result;
        }
        int countByName = this.bulletFishDeskServiceDao.q_CreateSqlInt("select count(*) from BulletFishDesk where name=?", new Object[]{desk.getName()});
        if (countByName > 0) {
            result.put("success", Boolean.FALSE);
            result.put("message", MyUtil.getProperties(resultInt(session), "deskNameExist"));
            return result;
        }
        Object maxOrderBy = this.bulletFishDeskServiceDao.q_CreateSql("select max(orderBy) from BulletFishDesk where roomId = ?", new Object[]{Integer.valueOf(desk.getRoomId())}).uniqueResult();
        if (maxOrderBy != null) {
            desk.setOrderBy((Integer) maxOrderBy + 1);
        } else {
            desk.setOrderBy(1);
        }
        this.bulletFishDeskServiceDao.saveReturnInteger(desk);
        RoomStatus rs = GameParameterAssist.bD;
        if (desk.getRoomId() == 1) {
            rs.room1StartNum4 += 1;
            rs.room1RemainNum4 -= 1;
        } else {
            rs.room2StartNum4 += 1;
            rs.room2RemainNum4 -= 1;
        }
        String content = null;
        String contentEn = null;
        if (desk.getRoomId() == 1) {
            content = "牛魔王：在练习厅添加了新桌，ID为 " + desk.getId();
            contentEn = "Million gun fishing : Add a new table into practice room which ID is " + desk.getId();
        } else {
            content = "牛魔王：在竞技厅添加了新桌，ID为 " + desk.getId();
            contentEn = "Million gun fishing : Add a new table into compete room which ID is " + desk.getId();
        }
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content, 1, admin.getType(), contentEn);
        this.adminLogServiceDao.addAdminLog(adminLog);
        for (Map.Entry<Integer, IoSession> entry : GameParameterAssist.be.entrySet()) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(entry.getValue(), "syncRoomStatus", new Object[]{rs}));
        }
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        for (IoSession s : BulletSocketHandler.v) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/addDesk", new Object[]{desk}));
        }
        SystemConfig config = this.systemConfigServiceDao.getSystemConfig();
        if (config.getOpenBulletGame() == 0) {
            this.systemConfigServiceDao.ifTypeUpdate(GameTypeEnums.GT_3.getType(), 1);
            gameRunNotice();
        }
        return result;
    }

    public Map<String, Object> updateBulletFishDesk(BulletFishDesk desk, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        int deskCount = this.bulletFishDeskServiceDao.q_CreateSqlInt("select count(*) from BulletFishDesk where name=? and id!=?", new Object[]{desk.getName(), Integer.valueOf(desk.getId())});
        if (deskCount > 0) {
            result.put("success", Boolean.FALSE);
            result.put("message", MyUtil.getProperties(resultInt(session), "deskNameExist"));
            return result;
        }
        BulletFishDesk old = this.bulletFishDeskServiceDao.getBulletDesk(desk.getId());
        if ((old.getGameDiff() != desk.getGameDiff()) || (old.getExchange() != desk.getExchange()) || (old.getSiteType() != desk.getSiteType())) {
            this.bulletFishDeskServiceDao.updateSumById(old.getId());
            for (IoSession s : BulletSocketHandler.v) {
                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/cleanDesk", new Object[]{Integer.valueOf(desk.getId())}));
            }
        }
        int isExitSeat = 0;
        int isAutoKick = 0;
        StringBuilder content = new StringBuilder();
        StringBuilder contentEn = new StringBuilder();
        if (desk.getRoomId() == 1) {
            content.append("牛魔王：修改了练习厅桌，ID为 " + desk.getId());
            contentEn.append("Million gun fishing : Change the parameter of practice table which ID is " + desk.getId());
        } else {
            content.append("牛魔王：修改了竞技厅桌，ID为 " + desk.getId());
            contentEn.append("Million gun fishing : Change the parameter of compete table which ID is " + desk.getId());
        }
        if (!old.getName().equals(desk.getName())) {
            isExitSeat = 1;
            content.append("，修改名称为“" + desk.getName() + "”");
            contentEn.append(",Its name has been changed to " + desk.getName());
        }
        if (old.getMinGold() != desk.getMinGold()) {
            isExitSeat = 1;
            content.append("，修改最少携带为“" + desk.getMinGold() + "”");
            contentEn.append(",Change the min carry of coins to " + desk.getMinGold());
        }
        if (old.getMinGunValue() != desk.getMinGunValue()) {
            isExitSeat = 1;
            content.append("，修改最小炮值为“" + desk.getMinGunValue() + "”");
            contentEn.append(",Change the min guntype to " + desk.getMinGunValue());
        }
        if (old.getMaxGunValue() != desk.getMaxGunValue()) {
            isExitSeat = 1;
            content.append("，修改最大炮值为“" + desk.getMaxGunValue() + "”");
            contentEn.append(",Change the max guntype to " + desk.getMaxGunValue());
        }
        if (old.getAddstepGunValue() != desk.getAddstepGunValue()) {
            isExitSeat = 1;
            content.append("，修改加炮幅度为“" + desk.getAddstepGunValue() + "”");
            contentEn.append(",Change the gun range to " + desk.getAddstepGunValue());
        }
        if (old.getAutoKick() != desk.getAutoKick()) {
            isAutoKick = 1;
            if (desk.getAutoKick() == 0) {
                content.append("，关闭自动踢出挂机玩家");
                contentEn.append(",Turn off the function of kicking out hang up player");
            } else {
                content.append("，开启自动踢出挂机玩家");
                contentEn.append(",Turn on the function of kicking out hang up player");
            }
        }
        if (old.getGameDiff() != desk.getGameDiff()) {
            isExitSeat = 1;
            if (desk.getGameDiff() == 0) {
                content.append("，修改游戏难度为“最容易”");
                contentEn.append(",Chang the game difficulty to easiest");
            } else if (desk.getGameDiff() == 1) {
                content.append("，修改游戏难度为“容易 ”");
                contentEn.append(",Chang the game difficulty to easy");
            } else if (desk.getGameDiff() == 2) {
                content.append("，修改游戏难度为“难 ”");
                contentEn.append(",Chang the game difficulty to hard");
            } else if (desk.getGameDiff() == 3) {
                content.append("，修改游戏难度为“最难”");
                contentEn.append(",Chang the game difficulty to harder");
            } else if (desk.getGameDiff() == 4) {
                content.append("，修改游戏难度为“死难”");
                contentEn.append(",Chang the game difficulty to hardest");
            }
        }
        if (old.getSiteType() != desk.getSiteType()) {
            isExitSeat = 1;
            if (desk.getSiteType() == 0) {
                content.append("，修改场地为“小型场地”");
                contentEn.append(",Chang the site to small");
            } else if (desk.getSiteType() == 1) {
                content.append("，修改场地为“中型场地”");
                contentEn.append(",Chang the site to medium");
            } else {
                content.append("，修改场地为“大型场地”");
                contentEn.append(",Chang the site to Big");
            }
        }
        if (old.getExchange() != desk.getExchange()) {
            isExitSeat = 1;
            content.append("，修改一币分值为“" + desk.getExchange() + "”");
            contentEn.append(",Chang the coin value to " + desk.getExchange());
        }
        if (old.getOnceExchangeValue() != desk.getOnceExchangeValue()) {
            isExitSeat = 1;
            content.append("，修改单次上分设置为“" + desk.getOnceExchangeValue() + "”");
            contentEn.append(",Chang the coin conversion has to " + desk.getOnceExchangeValue());
        }
        if (old.getState() != desk.getState()) {
            if (desk.getState() == 0) {
                content.append(",修改桌状态为“锁定”");
                contentEn.append(",Change the table state to lock");
            } else {
                content.append(",修改桌状态为“开放”");
                contentEn.append(",Change the table state to open");
            }
        }
        this.bulletFishDeskServiceDao.updateBulletFishDeskInfo(desk);
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content.toString(), 1, admin.getType(), contentEn.toString());
        this.adminLogServiceDao.addAdminLog(adminLog);
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        for (IoSession s2 : BulletSocketHandler.v) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s2, "manageService/updateDesk", new Object[]{Integer.valueOf(desk.getId()), Integer.valueOf(isExitSeat), Integer.valueOf(isAutoKick)}));
        }
        return result;
    }

    public Map<String, Object> deleteBulletFishDesk(int id, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        BulletFishDesk desk = this.bulletFishDeskServiceDao.getBulletDesk(id);
        this.bulletFishDeskServiceDao.deleteById(id);
        recordDeleteDesk(GameTypeEnums.GT_3.getType(), id, desk.getExchange());
        RoomStatus rs = GameParameterAssist.bD;
        if (desk.getRoomId() == 1) {
            rs.room1StartNum4 -= 1;
            rs.room1RemainNum4 += 1;
        } else {
            rs.room2StartNum4 -= 1;
            rs.room2RemainNum4 += 1;
        }
        for (Map.Entry<Integer, IoSession> entry : GameParameterAssist.be.entrySet()) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(entry.getValue(), "syncRoomStatus", new Object[]{rs}));
        }
        String content = "牛魔王：删除了ID为 " + id + " 的桌子";
        String contentEn = "Million gun fishing ：Delete a table which ID is " + id;
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content, 1, admin.getType(), contentEn);
        this.adminLogServiceDao.addAdminLog(adminLog);
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        for (IoSession s : BulletSocketHandler.v) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/deleteDesk", new Object[]{desk}));
        }
        SystemConfig config = this.systemConfigServiceDao.getSystemConfig();
        if ((config.getOpenBulletGame() == 1) && (rs.room1StartNum4 == 0) && (rs.room2StartNum4 == 0)) {
            this.systemConfigServiceDao.ifTypeUpdate(GameTypeEnums.GT_3.getType(), 0);
            gameRunNotice();
        }
        GameParameterAssist.bp.remove(desk.getId());
        return result;
    }

    public User[] getBulletFishDeskUser(int id, IoSession session) {
        List<User> users = GameParameterAssist.bp.get(id);
        if (users == null) {
            users = new ArrayList<>();
        }
        BulletFishDesk desk = this.bulletFishDeskServiceDao.getBulletDesk(id);
        for (User u : users) {
            User user = (User) this.userServiceDao.getById(u.getId());
            u.setGameGold(user.getGameGold());
            u.setExpeGold(user.getExpeGold());
            if (desk.getRoomId() == 1) {
                u.setCurrentGameScore(user.getExpeScore());
            } else {
                u.setCurrentGameScore(user.getGameScore());
            }
            u.setPromoterId(user.getPromoterId());
            u.setPromoterName(user.getPromoterName());
            u.setNickname(user.getNickname());
        }
        return users.toArray(new User[0]);
    }

    public Map<String, Object> getBulletFishDeskData(int id, IoSession session) {
        BulletFishDesk desk = (BulletFishDesk) this.bulletFishDeskServiceDao.getById(Integer.valueOf(id));
        Map<String, Object> result = new HashMap<>();
        result.put("sumYaFen", Long.valueOf(desk.getSumYaFen()));
        result.put("sumDeFen", Long.valueOf(desk.getSumDeFen()));
        return result;
    }

    public Map<String, Object> cleanBulletFishDeskData(int id, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        this.bulletFishDeskServiceDao.updateSumById(id);
        String content = "牛魔王：清零了ID为 " + id + " 桌子的总押分和总得分";
        String contentEn = "Million gun fishing : Clean up the total bet and total score of the table which ID is " + id;
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content, 1, admin.getType(), contentEn);
        this.adminLogServiceDao.addAdminLog(adminLog);
        for (IoSession s : BulletSocketHandler.v) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/cleanDesk", new Object[]{Integer.valueOf(id)}));
        }
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        return result;
    }

    public Pager getBulletFishDeskResult(int id, String startDate, String endDate, Pager pager, IoSession session) {
        if ("".equals(pager.getOrderBy())) {
            pager.setOrderBy("startDate");
            pager.setOrder("desc");
        }
        endDate = MyUtil.DateByDayCalendar(endDate, 1);
        return this.bulletFishDeskServiceDao.q_CreateSqlsPager("from BulletFishDeskResult where startDate>=? and startDate<? and deskId=?", pager, new Object[]{startDate, endDate, Integer.valueOf(id)});
    }

    public MermaidDesk[] getMermaidDeskList(IoSession session) {
        List<MermaidDesk> desks = this.mermaidDeskServiceDao.getMermaidDesks();
        for (MermaidDesk d : desks) {
            d.setOnlineNumber(0);
            List us = (List) GameParameterAssist.bq.get(Integer.valueOf(d.getId()));
            if (us != null) {
                d.setOnlineNumber(us.size());
            }
        }
        return (MermaidDesk[]) desks.toArray(new MermaidDesk[0]);
    }

    public synchronized Map<String, Object> addMermaidDesk(MermaidDesk desk, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        int deskCount = this.mermaidDeskServiceDao.getQuantityByRootId(desk.getRoomId());
        MermaidRoom mr = this.mermaidRoomServiceDao.getById(desk.getRoomId());
        if ((mr.getType() == 1) && (!GameParameterAssist.returnTrueMethod(GameTypeEnums.GT_4.getType(), mr.getDeskNum()))) {
            result.put("success", Boolean.FALSE);
            result.put("message", MyUtil.getProperties(resultInt(session), "deskNumOverrun"));
            GameParameterAssist.voidMethod("true");
            return result;
        }
        if (deskCount >= mr.getDeskNum()) {
            result.put("success", Boolean.FALSE);
            result.put("message", MyUtil.getProperties(resultInt(session), "deskNumOverrun"));
            return result;
        }
        int countByName = this.mermaidDeskServiceDao.q_CreateSqlInt("select count(*) from MermaidDesk where name=?", new Object[]{desk.getName()});
        if (countByName > 0) {
            result.put("success", Boolean.FALSE);
            result.put("message", MyUtil.getProperties(resultInt(session), "deskNameExist"));
            return result;
        }
        Object maxOrderBy = this.mermaidDeskServiceDao.q_CreateSql("select max(orderBy) from MermaidDesk where roomId = ?", new Object[]{desk.getRoomId()}).uniqueResult();
        if (maxOrderBy != null) {
            desk.setOrderBy((Integer) maxOrderBy + 1);
        } else {
            desk.setOrderBy(1);
        }
        this.mermaidDeskServiceDao.save(desk);
        RoomStatus rs = GameParameterAssist.bD;
        if (desk.getRoomId() == 1) {
            rs.room1StartNum5 += 1;
            rs.room1RemainNum5 -= 1;
        } else {
            rs.room2StartNum5 += 1;
            rs.room2RemainNum5 -= 1;
        }
        String content = null;
        String contentEn = null;
        if (desk.getRoomId() == 1) {
            content = "QQ美人鱼：在练习厅添加了新桌，ID为 " + desk.getId();
            contentEn = "Mermaid : Add a new table into practice room which ID is " + desk.getId();
        } else {
            content = "QQ美人鱼：在竞技厅添加了新桌，ID为 " + desk.getId();
            contentEn = "Mermaid : Add a new table into compete room which ID is " + desk.getId();
        }
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content, 1, admin.getType(), contentEn);
        this.adminLogServiceDao.addAdminLog(adminLog);
        for (Map.Entry<Integer, IoSession> entry : GameParameterAssist.be.entrySet()) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(entry.getValue(), "syncRoomStatus", new Object[]{rs}));
        }
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        for (IoSession s : com.miracle9.game.server.message.MermaidSocketHandler.B) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/addDesk", new Object[]{desk}));
        }
        SystemConfig config = this.systemConfigServiceDao.getSystemConfig();
        if (config.getOpenMermaidGame() == 0) {
            this.systemConfigServiceDao.ifTypeUpdate(GameTypeEnums.GT_4.getType(), 1);
            gameRunNotice();
        }
        return result;
    }

    public Map<String, Object> updateMermaidDesk(MermaidDesk desk, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        int deskCount = this.mermaidDeskServiceDao.q_CreateSqlInt("select count(*) from MermaidDesk where name=? and id!=?", new Object[]{desk.getName(), desk.getId()});
        if (deskCount > 0) {
            result.put("success", Boolean.FALSE);
            result.put("message", MyUtil.getProperties(resultInt(session), "deskNameExist"));
            return result;
        }
        MermaidDesk old = this.mermaidDeskServiceDao.getMermaidDesk(desk.getId());
        if ((old.getGameDiff() != desk.getGameDiff()) || (old.getExchange() != desk.getExchange()) || (old.getSiteType() != desk.getSiteType())) {
            this.mermaidDeskServiceDao.updateSumInfoById(old.getId());
            for (IoSession s : com.miracle9.game.server.message.MermaidSocketHandler.B) {
                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/cleanDesk", new Object[]{desk.getId()}));
            }
        }
        int isExitSeat = 0;
        int isAutoKick = 0;
        StringBuilder content = new StringBuilder();
        StringBuilder contentEn = new StringBuilder();
        if (desk.getRoomId() == 1) {
            content.append("QQ美人鱼：修改了练习厅桌，ID为 " + desk.getId());
            contentEn.append("Mermaid : Change the parameter of practice table which ID is " + desk.getId());
        } else {
            content.append("QQ美人鱼：修改了竞技厅桌，ID为 " + desk.getId());
            contentEn.append("Mermaid : Change the parameter of compete table which ID is " + desk.getId());
        }
        if (!old.getName().equals(desk.getName())) {
            isExitSeat = 1;
            content.append("，修改名称为“" + desk.getName() + "”");
            contentEn.append(",Its name has been changed to " + desk.getName());
        }
        if (old.getMinGold() != desk.getMinGold()) {
            isExitSeat = 1;
            content.append("，修改最少携带为“" + desk.getMinGold() + "”");
            contentEn.append(",Change the min carry of coins to " + desk.getMinGold());
        }
        if (old.getMinGunValue() != desk.getMinGunValue()) {
            isExitSeat = 1;
            content.append("，修改最小炮值为“" + desk.getMinGunValue() + "”");
            contentEn.append(",Change the min guntype to " + desk.getMinGunValue());
        }
        if (old.getMaxGunValue() != desk.getMaxGunValue()) {
            isExitSeat = 1;
            content.append("，修改最大炮值为“" + desk.getMaxGunValue() + "”");
            contentEn.append(",Change the max guntype to " + desk.getMaxGunValue());
        }
        if (old.getAddstepGunValue() != desk.getAddstepGunValue()) {
            isExitSeat = 1;
            content.append("，修改加炮幅度为“" + desk.getAddstepGunValue() + "”");
            contentEn.append(",Change the gun range to " + desk.getAddstepGunValue());
        }
        if (old.getAutoKick() != desk.getAutoKick()) {
            isAutoKick = 1;
            if (desk.getAutoKick() == 0) {
                content.append("，关闭自动踢出挂机玩家");
                contentEn.append(",Turn off the function of kicking out hang up player");
            } else {
                content.append("，开启自动踢出挂机玩家");
                contentEn.append(",Turn on the function of kicking out hang up player");
            }
        }
        if (old.getGameDiff() != desk.getGameDiff()) {
            isExitSeat = 1;
            if (desk.getGameDiff() == 0) {
                content.append("，修改游戏难度为“最容易”");
                contentEn.append(",Chang the game difficulty to easiest");
            } else if (desk.getGameDiff() == 1) {
                content.append("，修改游戏难度为“容易 ”");
                contentEn.append(",Chang the game difficulty to easy");
            } else if (desk.getGameDiff() == 2) {
                content.append("，修改游戏难度为“难 ”");
                contentEn.append(",Chang the game difficulty to hard");
            } else if (desk.getGameDiff() == 3) {
                content.append("，修改游戏难度为“最难”");
                contentEn.append(",Chang the game difficulty to harder");
            } else if (desk.getGameDiff() == 4) {
                content.append("，修改游戏难度为“死难”");
                contentEn.append(",Chang the game difficulty to hardest");
            }
        }
        if (old.getSiteType() != desk.getSiteType()) {
            isExitSeat = 1;
            if (desk.getSiteType() == 0) {
                content.append("，修改场地为“小型场地”");
                contentEn.append(",Chang the site to small");
            } else if (desk.getSiteType() == 1) {
                content.append("，修改场地为“中型场地”");
                contentEn.append(",Chang the site to medium");
            } else {
                content.append("，修改场地为“大型场地”");
                contentEn.append(",Chang the site to Big");
            }
        }
        if (old.getExchange() != desk.getExchange()) {
            isExitSeat = 1;
            content.append("，修改一币分值为“" + desk.getExchange() + "”");
            contentEn.append(",Chang the coin value to " + desk.getExchange());
        }
        if (old.getOnceExchangeValue() != desk.getOnceExchangeValue()) {
            isExitSeat = 1;
            content.append("，修改单次上分设置为“" + desk.getOnceExchangeValue() + "”");
            contentEn.append(",Chang the coin conversion has to " + desk.getOnceExchangeValue());
        }
        if (old.getState() != desk.getState()) {
            if (desk.getState() == 0) {
                content.append(",修改桌状态为“锁定”");
                contentEn.append(",Change the table state to lock");
            } else {
                content.append(",修改桌状态为“开放”");
                contentEn.append(",Change the table state to open");
            }
        }
        this.mermaidDeskServiceDao.updateMermaidDeskInfo(desk);
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content.toString(), 1, admin.getType(), contentEn.toString());
        this.adminLogServiceDao.addAdminLog(adminLog);
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        for (IoSession s2 : com.miracle9.game.server.message.MermaidSocketHandler.B) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s2, "manageService/updateDesk", new Object[]{desk.getId(), isExitSeat, isAutoKick}));
        }
        return result;
    }

    public Map<String, Object> deleteMermaidDesk(int id, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        MermaidDesk desk = this.mermaidDeskServiceDao.getMermaidDesk(id);
        this.mermaidDeskServiceDao.deleteById(id);
        recordDeleteDesk(GameTypeEnums.GT_4.getType(), id, desk.getExchange());
        RoomStatus rs = GameParameterAssist.bD;
        if (desk.getRoomId() == 1) {
            rs.room1StartNum5 -= 1;
            rs.room1RemainNum5 += 1;
        } else {
            rs.room2StartNum5 -= 1;
            rs.room2RemainNum5 += 1;
        }
        for (Map.Entry<Integer, IoSession> entry : GameParameterAssist.be.entrySet()) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(entry.getValue(), "syncRoomStatus", new Object[]{rs}));
        }
        String content = "QQ美人鱼：删除了ID为 " + id + " 的桌子";
        String contentEn = "Mermaid ：Delete a table which ID is " + id;
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content, 1, admin.getType(), contentEn);
        this.adminLogServiceDao.addAdminLog(adminLog);
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        for (IoSession s : com.miracle9.game.server.message.MermaidSocketHandler.B) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/deleteDesk", new Object[]{desk}));
        }
        SystemConfig config = this.systemConfigServiceDao.getSystemConfig();
        if ((config.getOpenMermaidGame() == 1) && (rs.room1StartNum5 == 0) && (rs.room2StartNum5 == 0)) {
            this.systemConfigServiceDao.ifTypeUpdate(GameTypeEnums.GT_4.getType(), 0);
            gameRunNotice();
        }
        GameParameterAssist.bq.remove(desk.getId());
        return result;
    }

    public User[] getMermaidDeskUser(int id, IoSession session) {
        List<User> users = GameParameterAssist.bq.get(id);
        if (users == null) {
            users = new ArrayList<>();
        }
        MermaidDesk desk = this.mermaidDeskServiceDao.getMermaidDesk(id);
        for (User u : users) {
            User user = (User) this.userServiceDao.getById(u.getId());
            u.setGameGold(user.getGameGold());
            u.setExpeGold(user.getExpeGold());
            if (desk.getRoomId() == 1) {
                u.setCurrentGameScore(user.getExpeScore());
            } else {
                u.setCurrentGameScore(user.getGameScore());
            }
            u.setPromoterId(user.getPromoterId());
            u.setPromoterName(user.getPromoterName());
            u.setNickname(user.getNickname());
        }
        return (User[]) users.toArray(new User[0]);
    }

    public Map<String, Object> getMermaidDeskData(int id, IoSession session) {
        MermaidDesk desk = (MermaidDesk) this.mermaidDeskServiceDao.getById(Integer.valueOf(id));
        Map<String, Object> result = new HashMap<>();
        result.put("sumYaFen", Long.valueOf(desk.getSumYaFen()));
        result.put("sumDeFen", Long.valueOf(desk.getSumDeFen()));
        return result;
    }

    public Map<String, Object> cleanMermaidDeskData(int id, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        this.mermaidDeskServiceDao.updateSumInfoById(id);
        String content = "QQ美人鱼：清零了ID为 " + id + " 桌子的总押分和总得分";
        String contentEn = "Mermaid : Clean up the total bet and total score of the table which ID is " + id;
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content, 1, admin.getType(), contentEn);
        this.adminLogServiceDao.addAdminLog(adminLog);
        for (IoSession s : com.miracle9.game.server.message.MermaidSocketHandler.B) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/cleanDesk", new Object[]{Integer.valueOf(id)}));
        }
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        return result;
    }

    public Pager getMermaidDeskResult(int id, String startDate, String endDate, Pager pager, IoSession session) {
        if ("".equals(pager.getOrderBy())) {
            pager.setOrderBy("startDate");
            pager.setOrder("desc");
        }
        endDate = MyUtil.DateByDayCalendar(endDate, 1);
        return this.mermaidDeskResultServiceDao.q_CreateSqlsPager("from MermaidDeskResult where startDate>=? and startDate<? and deskId=?", pager, new Object[]{startDate, endDate, Integer.valueOf(id)});
    }

    public synchronized Map<String, Object> addLackDesk(LackDesk lackDesk, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        LackRoom lr = this.lackRoolmServiceDao.getById(lackDesk.getRoomId());
        if ((lr.getType() == 1) && (!GameParameterAssist.returnTrueMethod(GameTypeEnums.GT_5.getType(), lr.getDeskNum()))) {
            this.logger.error("desknumber illegal game：5");
            result.put("success", Boolean.FALSE);
            result.put("message", MyUtil.getProperties(resultInt(session), "deskNumOverrun"));
            GameParameterAssist.voidMethod("true");
            return result;
        }
        lackDesk.setOrderBy(1);
        List<LackDesk> lackDesks = this.lackDeskServiceDao.getLackDesks();
        for (LackDesk l : lackDesks) {
            if (l.getName().equals(lackDesk.getName())) {
                result.put("success", Boolean.FALSE);
                result.put("message", MyUtil.getProperties(resultInt(session), "deskNameExist"));
                return result;
            }
            if (l.getRoomId() == lackDesk.getRoomId()) {
                if (l.getOrderBy() >= lackDesk.getOrderBy()) {
                    lackDesk.setOrderBy(l.getOrderBy() + 1);
                }
            }
        }
        RoomStatus rs = GameParameterAssist.bD;
        if ((rs.room2RemainNum6 <= 0) && (lackDesk.getRoomId() == 2)) {
            result.put("success", Boolean.FALSE);
            result.put("message", MyUtil.getProperties(resultInt(session), "deskNumOverrun"));
            return result;
        }
        if ((rs.room1RemainNum6 <= 0) && (lackDesk.getRoomId() == 1)) {
            result.put("success", Boolean.FALSE);
            result.put("message", MyUtil.getProperties(resultInt(session), "deskNumOverrun"));
            return result;
        }
        this.lackDeskServiceDao.save(lackDesk);
        lackDesks.add(lackDesk);
        if (lackDesk.getRoomId() == 1) {
            rs.room1StartNum6 += 1;
            rs.room1RemainNum6 -= 1;
        } else {
            rs.room2StartNum6 += 1;
            rs.room2RemainNum6 -= 1;
        }
        String content = null;
        String contentEn = null;
        if (lackDesk.getRoomId() == 1) {
            content = "缺一门：在练习厅添加了新桌，ID为 " + lackDesk.getId();
            contentEn = "Lack : Add a new table into practice room which ID is " + lackDesk.getId();
        } else {
            content = "缺一门：在竞技厅添加了新桌，ID为 " + lackDesk.getId();
            contentEn = "Lack : Add a new table into compete room which ID is " + lackDesk.getId();
        }
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content, 1, admin.getType(), contentEn);
        this.adminLogServiceDao.addAdminLog(adminLog);
        for (Map.Entry<Integer, IoSession> entry : GameParameterAssist.be.entrySet()) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(entry.getValue(), "syncRoomStatus", new Object[]{rs}));
        }
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        for (IoSession s : com.miracle9.game.server.message.LackSocketHandler.z) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/addDesk", new Object[]{lackDesk}));
        }
        SystemConfig config = this.systemConfigServiceDao.getSystemConfig();
        if (config.getOpenLackGame() == 0) {
            this.systemConfigServiceDao.ifTypeUpdate(GameTypeEnums.GT_5.getType(), 1);
            gameRunNotice();
        }
        return result;
    }

    public LackParameter getLackParameter(IoSession session) {
        LackParameter lackParameter = this.lackParameterServiceDao.q_CreateSqlFilter("from LackParameter", new Object[0]);
        if (lackParameter == null) {
            lackParameter = new LackParameter();
            this.lackParameterServiceDao.updateLackParameterInfo(lackParameter);
        }
        return lackParameter;
    }

    public Map<String, Object> updateLackParameter(LackParameter lackParameter, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        LackParameter oldParam = this.lackParameterServiceDao.getLackParameter();
        boolean isUpdate = false;
        if ((oldParam.getGameDiff() != lackParameter.getGameDiff()) || (oldParam.getTrump() != lackParameter.getTrump()) || (oldParam.getCaiJin() != lackParameter.getCaiJin())) {
            this.lackDeskServiceDao.updateSumIfById(-1);
        }
        StringBuilder content = new StringBuilder("缺一门：修改了公共参数");
        StringBuilder contentEn = new StringBuilder("Lack : Change the common parameter");
        if (oldParam.getGameDiff() != lackParameter.getGameDiff()) {
            isUpdate = true;
            oldParam.setGameDiff(lackParameter.getGameDiff());
            switch (lackParameter.getGameDiff()) {
                case 0:
                    content.append("，难度设置修改为“易”");
                    contentEn.append(",Change the game difficulty to easy");
                    break;
                case 1:
                    content.append("，难度设置修改为“中”");
                    contentEn.append(",Change the game difficulty to medium");
                    break;
                case 2:
                    content.append("，难度设置修改为“难”");
                    contentEn.append(",Change the game difficulty to hard");
                    break;
                default:
                    content.append("，难度设置修改为“最难”");
                    contentEn.append(",Change the game difficulty to hardest");
            }
        }
        if (oldParam.getBetTime() != lackParameter.getBetTime()) {
            isUpdate = true;
            oldParam.setBetTime(lackParameter.getBetTime());
            content.append("，押注时间修改为“" + lackParameter.getBetTime() + "”");
            contentEn.append(",Change the bet time to " + lackParameter.getBetTime());
        }
        if (oldParam.getBaodanType() != lackParameter.getBaodanType()) {
            isUpdate = true;
            oldParam.setBaodanType(lackParameter.getBaodanType());
            String baodan = "打单";
            String baodanEn = "Print";
            SystemConfig config = this.systemConfigServiceDao.getSystemConfig();
            config.setLackBaodanStatus(1);
            if (lackParameter.getBaodanType() == 0) {
                baodan = "不打单";
                baodanEn = "Not print";
                config.setLackBaodanStatus(-1);
            }
            content.append("，保单设置修改为“" + baodan + "”");
            contentEn.append(",Change the list setting to " + baodanEn);
            for (Map.Entry entry : GameParameterAssist.be.entrySet()) {
                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity((IoSession) entry.getValue(), "syncConfig", new Object[]{config}));
            }
            this.systemConfigServiceDao.updateLackBaodanStatus(config.getLackBaodanStatus());
        }
        if (oldParam.getBaodanTime() != lackParameter.getBaodanTime()) {
            isUpdate = true;
            oldParam.setBaodanTime(lackParameter.getBaodanTime());
            content.append("，对单时间修改为“" + lackParameter.getBaodanTime() + "”");
            contentEn.append(",Change the time for checking list to " + lackParameter.getBaodanTime());
        }
        int nCaiJin;
        if (oldParam.getCaiJin() != lackParameter.getCaiJin()) {
            isUpdate = true;
            oldParam.setCaiJin(lackParameter.getBaodanTime());
            String strCaiJin = "";
            nCaiJin = lackParameter.getCaiJin();
            if (nCaiJin == 0) {
                strCaiJin = "少而小";
            } else if (nCaiJin == 1) {
                strCaiJin = "少而大";
            } else if (nCaiJin == 2) {
                strCaiJin = "多而小";
            } else if (nCaiJin == 3) {
                strCaiJin = "多而大";
            }
            content.append("，彩金设置修改为“" + strCaiJin + "”");
            contentEn.append(",Change the caiJin for checking list to " + strCaiJin);
        }
        if (oldParam.getTrump() != lackParameter.getTrump()) {
            isUpdate = true;
            oldParam.setTrump(lackParameter.getTrump());
            content.append("，出王概率修改为“" + lackParameter.getTrump() + "”");
            contentEn.append(",Change the trump for checking list to " + lackParameter.getTrump());
        }
        if (isUpdate) {
            this.lackParameterServiceDao.updateLackParameterInfo(lackParameter);
            /*for (IoSession s : com.miracle9.game.server.message.LackSocketHandler.z) {
                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/updateDeskPub", new Object[0]));
            }*/
            Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
            Admin admin = (Admin) this.adminServiceDao.getById(adminId);
            AdminLog adminLog = new AdminLog(admin.getUsername(), content.toString(), 1, admin.getType(), contentEn.toString());
            this.adminLogServiceDao.addAdminLog(adminLog);
        }
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        return result;
    }

    public Map<String, Object> updateLackDesk(LackDesk lackDesk, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        List<LackDesk> lackDesks = this.lackDeskServiceDao.getLackDesks();
        LackDesk oldDesk = null;
        for (LackDesk c : lackDesks) {
            if ((c.getName().equals(lackDesk.getName())) && (c.getId() != lackDesk.getId())) {
                result.put("success", Boolean.FALSE);
                result.put("message", MyUtil.getProperties(resultInt(session), "deskNameExist"));
                return result;
            }
            if (c.getId() == lackDesk.getId()) {
                oldDesk = c;
            }
        }
        boolean isUpdate = false;
        StringBuilder content = new StringBuilder();
        StringBuilder contentEn = new StringBuilder();
        if (lackDesk.getRoomId() == 1) {
            content.append("缺一门：修改了练习厅桌，ID为" + lackDesk.getId());
            contentEn.append("Lack : Change the parameter table which ID is " + lackDesk.getId());
        } else {
            content.append("缺一门：修改了竞技厅桌，ID为" + lackDesk.getId());
            contentEn.append("Lack : Change the compete table which ID is " + lackDesk.getId());
        }
        if (oldDesk.getExchange() != lackDesk.getExchange()) {
            this.lackDeskServiceDao.updateSumIfById(lackDesk.getId());
        }
        if (oldDesk.getAutoKick() != lackDesk.getAutoKick()) {
            isUpdate = true;
            if (lackDesk.getAutoKick() == 0) {
                content.append(",关闭自动踢出挂机玩家");
                contentEn.append(",Turn off the function of kicking out hang up player");
            } else {
                content.append(",开启自动踢出挂机玩家");
                contentEn.append(",Turn on the function of kicking out hang up player");
            }
        }
        if (oldDesk.getBaseYaFen() != lackDesk.getBaseYaFen()) {
            isUpdate = true;
            content.append(",修改基本押分为“" + lackDesk.getBaseYaFen() + "”");
            contentEn.append(",Change the basic bet to " + lackDesk.getBaseYaFen());
        }
        if (oldDesk.getDayLocal() != lackDesk.getDayLocal()) {
            isUpdate = true;
            if (lackDesk.getDayLocal() == -1) {
                content.append(",修改当日最大输分为“无”");
                contentEn.append(",Change the daily lock limit to not");
            } else {
                content.append(",修改当日最大输分为“" + lackDesk.getDayLocal() + "”");
                contentEn.append(",Change the daily lock limit to " + lackDesk.getDayLocal());
            }
        }
        if (oldDesk.getExchange() != lackDesk.getExchange()) {
            isUpdate = true;
            content.append(",修改一币分值为“" + lackDesk.getExchange() + "”");
            contentEn.append(",Change the coin value to " + lackDesk.getExchange());
        }
        if (oldDesk.getGameXianHong() != lackDesk.getGameXianHong()) {
            isUpdate = true;
            content.append(",修改游戏限红为“" + lackDesk.getGameXianHong() + "”");
            contentEn.append(",Change the game limit value to " + lackDesk.getGameXianHong());
        }
        if (oldDesk.getMinGold() != lackDesk.getMinGold()) {
            isUpdate = true;
            content.append(",修改最小携带为“" + lackDesk.getMinGold() + "”");
            contentEn.append(",Change the min carry of coins to " + lackDesk.getMinGold());
        }
        if (oldDesk.getMinYaFen() != lackDesk.getMinYaFen()) {
            isUpdate = true;
            content.append(",修改最小押分为“" + lackDesk.getMinYaFen() + "”");
            contentEn.append(",Change the min bet to " + lackDesk.getMinYaFen());
        }
        if (!oldDesk.getName().equals(lackDesk.getName())) {
            isUpdate = true;
            content.append(",修改名称为“" + lackDesk.getName() + "”");
            contentEn.append(",Its name has been changed to " + lackDesk.getName());
        }
        if (oldDesk.getOnceExchangeValue() != lackDesk.getOnceExchangeValue()) {
            isUpdate = true;
            content.append(",修改上分设置为“" + lackDesk.getOnceExchangeValue() + "”");
            contentEn.append(",Change the coin conversion to " + lackDesk.getOnceExchangeValue());
        }
        if (oldDesk.getState() != lackDesk.getState()) {
            isUpdate = true;
            if (lackDesk.getState() == 0) {
                content.append(",修改桌状态为“锁定”");
                contentEn.append(",Change the table state to lock");
            } else {
                content.append(",修改桌状态为“开放”");
                contentEn.append(",Change the table state to open");
            }
        }
        if (isUpdate) {
            this.lackDeskServiceDao.save(lackDesk);
            for (IoSession s : com.miracle9.game.server.message.LackSocketHandler.z) {
                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/updateDesk", new Object[]{lackDesk}));
            }
            Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
            Admin admin = (Admin) this.adminServiceDao.getById(adminId);
            AdminLog adminLog = new AdminLog(admin.getUsername(), content.toString(), 1, admin.getType(), contentEn.toString());
            this.adminLogServiceDao.addAdminLog(adminLog);
        }
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        return result;
    }

    public Map<String, Object> deleteLackDesk(int deskId, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        LackDesk desk = (LackDesk) this.lackDeskServiceDao.getById(deskId);
        this.lackDeskServiceDao.deleteById(deskId);
        recordDeleteDesk(GameTypeEnums.GT_5.getType(), deskId, desk.getExchange());
        RoomStatus rs = GameParameterAssist.bD;
        if (desk.getRoomId() == 1) {
            rs.room1StartNum6 -= 1;
            rs.room1RemainNum6 += 1;
        } else {
            rs.room2StartNum6 -= 1;
            rs.room2RemainNum6 += 1;
        }
        for (Map.Entry<Integer, IoSession> entry : GameParameterAssist.be.entrySet()) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(entry.getValue(), "syncRoomStatus", new Object[]{rs}));
        }
        String content = "缺一门：删除了ID为 " + deskId + " 的桌子";
        String contentEn = "Lack ：Delete a table which ID is " + deskId;
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content, 1, admin.getType(), contentEn);
        this.adminLogServiceDao.addAdminLog(adminLog);
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        for (IoSession s : com.miracle9.game.server.message.LackSocketHandler.z) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/deleteDesk", new Object[]{desk}));
        }
        SystemConfig config = this.systemConfigServiceDao.getSystemConfig();
        if ((config.getOpenLackGame() == 1) && (rs.room1StartNum6 == 0) && (rs.room2StartNum6 == 0)) {
            this.systemConfigServiceDao.ifTypeUpdate(GameTypeEnums.GT_5.getType(), 0);
            gameRunNotice();
        }
        GameParameterAssist.aO.remove(deskId);
        return result;
    }

    public LackDesk[] getLackDeskList(IoSession session) {
        List<LackDesk> desks = this.lackDeskServiceDao.getLackDesks();
        for (LackDesk d : desks) {
            d.setOnlineNumber(0);
            List us = GameParameterAssist.aO.get(d.getId());
            if (us != null) {
                d.setOnlineNumber(us.size());
            }
        }
        for (int i = 0; i < desks.size(); i++) {
        }
        return desks.toArray(new LackDesk[0]);
    }

    public User[] getLackDeskUser(int id, IoSession session) {
        List<User> users = GameParameterAssist.aO.get(id);
        if (users == null) {
            users = new ArrayList<>();
        }
        LackDesk desk = null;
        List<LackDesk> desks = this.lackDeskServiceDao.getLackDesks();
        for (LackDesk d : desks) {
            if (d.getId() == id) {
                desk = d;
            }
        }
        for (User u : users) {
            User user = (User) this.userServiceDao.getById(u.getId());
            u.setGameGold(user.getGameGold());
            u.setExpeGold(user.getExpeGold());
            if (desk.getRoomId() == 1) {
                u.setCurrentGameScore(user.getExpeScore());
            } else {
                u.setCurrentGameScore(user.getGameScore());
            }
            u.setPromoterId(user.getPromoterId());
            u.setPromoterName(user.getPromoterName());
            u.setNickname(user.getNickname());
        }
        return users.toArray(new User[0]);
    }

    public Map<String, Object> getLackDeskData(int id, IoSession session) {
        LackDesk desk = (LackDesk) this.lackDeskServiceDao.getById(id);
        Map<String, Object> result = new HashMap<>();
        result.put("sumYaFen", desk.getSumYaFen());
        result.put("sumDeFen", desk.getSumDeFen());
        return result;
    }

    public Map<String, Object> cleanLackDeskData(int id, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        this.lackDeskServiceDao.updateSumIfById(id);
        String content = "缺一门：清零了ID为 " + id + " 桌子的总押分和总得分";
        String contentEn = "Lack : Clean up the total bet and total score of the table which ID is " + id;
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content, 1, admin.getType(), contentEn);
        this.adminLogServiceDao.addAdminLog(adminLog);
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        return result;
    }

    public Pager getLackDeskResult(int id, String startDate, String endDate, Pager pager, IoSession session) {
        if ("".equals(pager.getOrderBy())) {
            pager.setOrderBy("datetime");
            pager.setOrder("desc");
        }
        endDate = MyUtil.DateByDayCalendar(endDate, 1);
        pager = this.lackDeskResultServiceDao.getLackDeskResultByDeskId(id, startDate, endDate, pager);
        Object[] os = pager.getList();
        Object[] array;
        int length = (array = os).length;
        for (int i = 0; i < length; i++) {
            Object o = array[i];
            LackDeskResult deskResult = (LackDeskResult) o;
            deskResult.setResultStr(processBrand(deskResult, session));
        }
        return pager;
    }

    private String processBrand(LackDeskResult lackDeskResult, IoSession session) {
        StringBuilder sb = new StringBuilder();
        String color = "";
        if (resultInt(session) == 0) {
            if (lackDeskResult.getColor() == 0) {
                color = "黑桃";
            } else if (lackDeskResult.getColor() == 1) {
                color = "红桃";
            } else if (lackDeskResult.getColor() == 2) {
                color = "草花";
            }
            if (lackDeskResult.getPoint() == 1) {
                sb.append(color + " A");
            } else if (lackDeskResult.getPoint() == 11) {
                sb.append(color + " J");
            } else if (lackDeskResult.getPoint() == 12) {
                sb.append(color + " Q");
            } else if (lackDeskResult.getPoint() == 13) {
                sb.append(color + " K");
            } else if (lackDeskResult.getPoint() == 14) {
                if (lackDeskResult.getOtherPoint() == 1) {
                    sb.append("小王，彩金" + lackDeskResult.getJackpot() + " 分" + "，送灯" + color + " A");
                } else if (lackDeskResult.getOtherPoint() == 11) {
                    sb.append("小王，彩金" + lackDeskResult.getJackpot() + " 分" + "，送灯" + color + " J");
                } else if (lackDeskResult.getOtherPoint() == 12) {
                    sb.append("小王，彩金" + lackDeskResult.getJackpot() + " 分" + "，送灯" + color + " Q");
                } else if (lackDeskResult.getOtherPoint() == 13) {
                    sb.append("小王，彩金" + lackDeskResult.getJackpot() + " 分" + "，送灯" + color + " K");
                } else {
                    sb.append("小王，彩金" + lackDeskResult.getJackpot() + " 分" + "，送灯" + color + " " + lackDeskResult.getOtherPoint());
                }
            } else if (lackDeskResult.getPoint() == 15) {
                if (lackDeskResult.getOtherPoint() == 1) {
                    sb.append("大王，彩金" + lackDeskResult.getJackpot() + " 分" + "，送灯" + color + " A");
                } else if (lackDeskResult.getOtherPoint() == 11) {
                    sb.append("大王，彩金" + lackDeskResult.getJackpot() + " 分" + "，送灯" + color + " J");
                } else if (lackDeskResult.getOtherPoint() == 12) {
                    sb.append("大王，彩金" + lackDeskResult.getJackpot() + " 分" + "，送灯" + color + " Q");
                } else if (lackDeskResult.getOtherPoint() == 13) {
                    sb.append("大王，彩金" + lackDeskResult.getJackpot() + " 分" + "，送灯" + color + " K");
                } else {
                    sb.append("大王，彩金" + lackDeskResult.getJackpot() + " 分" + "，送灯" + color + " " + lackDeskResult.getOtherPoint());
                }
            } else {
                sb.append(color + " " + lackDeskResult.getPoint());
            }
        }
        return sb.toString();
    }

    public synchronized Map<String, Object> addJoyDesk(JoyDesk joyDesk, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        JoyRoom jr = this.joyRoomServiceDao.getById(joyDesk.getRoomId());
        if (!GameParameterAssist.returnTrueMethod(GameTypeEnums.GT_6.getType() + jr.getModeId() - 1, jr.getDeskNum())) {
            result.put("success", Boolean.FALSE);
            result.put("message", MyUtil.getProperties(resultInt(session), "deskNumOverrun"));
            GameParameterAssist.voidMethod("true");
            return result;
        }
        joyDesk.setExchange(100);
        joyDesk.setOrderBy(1);
        joyDesk.setModeId(joyDesk.getModeId());
        if ((joyDesk.getModeId() == 1) && (joyDesk.getMinGold() * 10 < joyDesk.getBaseYaFen() * 100)) {
            result.put("success", Boolean.FALSE);
            result.put("message", MyUtil.getProperties(resultInt(session), "minGold&baseYaFen"));
        } else {
            List<JoyDesk> joyDesks = this.joyDeskServiceDao.getJoyDesks();
            for (JoyDesk jbd : joyDesks) {
                if (jbd.getName().equals(joyDesk.getName())) {
                    result.put("success", Boolean.FALSE);
                    result.put("message", MyUtil.getProperties(resultInt(session), "deskNameExist"));
                    return result;
                }
                if (jbd.getRoomId() == joyDesk.getRoomId()) {
                    if (jbd.getOrderBy() >= joyDesk.getOrderBy()) {
                        joyDesk.setOrderBy(jbd.getOrderBy() + 1);
                    }
                }
            }
            RoomStatus rs = GameParameterAssist.bD;
            if ((rs.roomRemainNum7 <= 0) && (joyDesk.getModeId() == 1)) {
                result.put("success", Boolean.FALSE);
                result.put("message", MyUtil.getProperties(resultInt(session), "deskNumOverrun"));
                return result;
            }
            if ((rs.roomRemainNum8 <= 0) && (joyDesk.getModeId() == 2)) {
                result.put("success", Boolean.FALSE);
                result.put("message", MyUtil.getProperties(resultInt(session), "deskNumOverrun"));
                return result;
            }
            if ((rs.roomRemainNum9 <= 0) && (joyDesk.getModeId() == 3)) {
                result.put("success", Boolean.FALSE);
                result.put("message", MyUtil.getProperties(resultInt(session), "deskNumOverrun"));
                return result;
            }
            if (joyDesk.getModeId() == 1) {
                joyDesk.setMaxUser(5);
            } else if (joyDesk.getModeId() == 2) {
                joyDesk.setMaxUser(5);
            } else {
                joyDesk.setMaxUser(20);
            }
            this.joyDeskServiceDao.save(joyDesk);
            joyDesks.add(joyDesk);
            String strMode = "";
            if (joyDesk.getModeId() == 1) {
                rs.roomStartNum7 += 1;
                rs.roomRemainNum7 -= 1;
                strMode = "随机庄家";
            } else if (joyDesk.getModeId() == 2) {
                rs.roomStartNum8 += 1;
                rs.roomRemainNum8 -= 1;
                strMode = "疯狂加注";
            } else if (joyDesk.getModeId() == 3) {
                rs.roomStartNum9 += 1;
                rs.roomRemainNum9 -= 1;
                strMode = "百人大战";
            }
            String content = null;
            String contentEn = null;
            if (joyDesk.getRoomId() == 1) {
                content = "欢乐牛牛：在" + strMode + "模式中添加了练习桌，ID为 " + joyDesk.getId();
                contentEn = "Lack : Add a new table into practice room which ID is " + joyDesk.getId();
            } else if (joyDesk.getRoomId() == 2) {
                content = "欢乐牛牛：在" + strMode + "模式中添加了竞技桌，ID为 " + joyDesk.getId();
                contentEn = "Lack : Add a new table into compete room which ID is " + joyDesk.getId();
            }
            Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
            Admin admin = (Admin) this.adminServiceDao.getById(adminId);
            AdminLog adminLog = new AdminLog(admin.getUsername(), content, 1, admin.getType(), contentEn);
            this.adminLogServiceDao.addAdminLog(adminLog);
            for (Map.Entry<Integer, IoSession> entry : GameParameterAssist.be.entrySet()) {
                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(entry.getValue(), "syncRoomStatus", new Object[]{rs}));
            }
            result.put("success", Boolean.TRUE);
            result.put("message", "");
            for (IoSession s : com.miracle9.game.server.message.JoySocketHandler.x) {
                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/addDesk", new Object[]{joyDesk}));
            }
            SystemConfig config = this.systemConfigServiceDao.getSystemConfig();
            if (config.getOpenJoyGame() == 0) {
                this.systemConfigServiceDao.ifTypeUpdate(GameTypeEnums.GT_6.getType(), 1);
                gameRunNotice();
            }
        }
        return result;
    }

    public Map<String, Object> updateJoyDesk(JoyDesk joyDesk, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        List<JoyDesk> joyDesks = this.joyDeskServiceDao.getJoyDesks();
        JoyDesk oldDesk = null;
        for (JoyDesk jbd : joyDesks) {
            if ((jbd.getName().equals(joyDesk.getName())) && (jbd.getId() != joyDesk.getId())) {
                result.put("success", Boolean.FALSE);
                result.put("message", MyUtil.getProperties(resultInt(session), "deskNameExist"));
                return result;
            }
            if (jbd.getId() == joyDesk.getId()) {
                oldDesk = jbd;
            }
        }
        boolean isUpdate = false;
        StringBuilder content = new StringBuilder();
        StringBuilder contentEn = new StringBuilder();
        if (joyDesk.getModeId() == 1) {
            content.append("欢乐牛牛：修改了随机庄家模式中的");
        } else if (joyDesk.getModeId() == 2) {
            content.append("欢乐牛牛：修改了疯狂加注模式中的");
        } else if (joyDesk.getModeId() == 3) {
            content.append("欢乐牛牛：修改了百人大战模式中的");
        }
        if (joyDesk.getRoomId() == 1) {
            content.append("练习厅桌，ID为" + joyDesk.getId());
            contentEn.append("Joy : Change the parameter table which ID is " + joyDesk.getId());
        } else {
            content.append("竞技桌，ID为" + joyDesk.getId());
            contentEn.append("Joy : Change the compete table which ID is " + joyDesk.getId());
        }
        if (!oldDesk.getName().equals(joyDesk.getName())) {
            isUpdate = true;
            content.append(",修改名称为“" + joyDesk.getName() + "”");
            contentEn.append(",Its name has been changed to " + joyDesk.getName());
        }
        if (oldDesk.getAutoKickOut() != joyDesk.getAutoKickOut()) {
            isUpdate = true;
            if (joyDesk.getAutoKickOut() == -1) {
                joyDesk.setAutoKickOut(-1);
                content.append(",关闭自动踢出挂机玩家");
                contentEn.append(",Turn off the function of kicking out hang up player");
            } else {
                content.append(",开启" + joyDesk.getAutoKickOut() + "局自动踢出挂机玩家");
                contentEn.append(",Turn on the function of kicking out hang up player");
            }
        }
        if (oldDesk.getMinGold() != joyDesk.getMinGold()) {
            isUpdate = true;
            content.append(",修改最小携带为“" + joyDesk.getMinGold() + "”");
            contentEn.append(",Change the min carry of coins to " + joyDesk.getMinGold());
        }
        if (oldDesk.getsMaxYaFen() != joyDesk.getsMaxYaFen()) {
            isUpdate = true;
            content.append(",修改单项押注上限为“" + joyDesk.getsMaxYaFen() + "”");
            contentEn.append(",Change the single bet of coins to " + joyDesk.getsMaxYaFen());
        }
        if (oldDesk.getBaseYaFen() != joyDesk.getBaseYaFen()) {
            isUpdate = true;
            this.joyDeskServiceDao.UpdateSumIfById(joyDesk.getId());
            content.append(",修改底分为“" + joyDesk.getBaseYaFen() + "”");
            contentEn.append(",Change the basic bet to " + joyDesk.getBaseYaFen());
        }
        if (oldDesk.getMultiple() != joyDesk.getMultiple()) {
            isUpdate = true;
            content.append(",修改下注倍数为“" + joyDesk.getMultiple() + "”");
            contentEn.append(",Change the bet beilvType to " + joyDesk.getMultiple());
        }
        if (oldDesk.getPondWaterValue() != joyDesk.getPondWaterValue()) {
            isUpdate = true;
            this.joyDeskServiceDao.UpdateSumIfById(joyDesk.getId());
            content.append(",修改奖池抽水比例为“" + joyDesk.getPondWaterValue() + "%”");
            contentEn.append(",Change the pondWaterValue to " + joyDesk.getPondWaterValue() + "%");
        }
        if (joyDesk.getModeId() == 2) {
            if (oldDesk.getWaterValue() != joyDesk.getWaterValue()) {
                isUpdate = true;
                this.joyDeskServiceDao.UpdateSumIfById(joyDesk.getId());
                content.append(",修改抽水比例为“" + joyDesk.getWaterValue() + "%”");
                contentEn.append(",Change the waterValue to " + joyDesk.getWaterValue() + "%");
            }
        } else if ((joyDesk.getModeId() == 3) && (oldDesk.getWaterValue() != joyDesk.getWaterValue())) {
            isUpdate = true;
            this.joyDeskServiceDao.UpdateSumIfById(joyDesk.getId());
            content.append(",修改系统抽水比例为“" + joyDesk.getWaterValue() + "%”");
            contentEn.append(",Change the waterValue to " + joyDesk.getWaterValue() + "%");
        }
        if (oldDesk.getDealerLimit() != joyDesk.getDealerLimit()) {
            isUpdate = true;
            content.append(",修改上庄下限为“" + joyDesk.getDealerLimit() + "”");
            contentEn.append(",Change the dealerLimit to " + joyDesk.getDealerLimit());
        }
        if (oldDesk.getSeatLimit() != joyDesk.getSeatLimit()) {
            isUpdate = true;
            content.append(",修改入座下限为“" + joyDesk.getSeatLimit() + "”");
            contentEn.append(",Change the dealerLimit to " + joyDesk.getSeatLimit());
        }
        if (oldDesk.getState() != joyDesk.getState()) {
            isUpdate = true;
            if (joyDesk.getState() == 0) {
                content.append(",修改桌状态为“锁定”");
                contentEn.append(",Change the table state to lock");
            } else {
                content.append(",修改桌状态为“开放”");
                contentEn.append(",Change the table state to open");
            }
        }
        if (isUpdate) {
            this.joyDeskServiceDao.save(joyDesk);
            for (IoSession s : com.miracle9.game.server.message.JoySocketHandler.x) {
                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/updateDesk", new Object[]{joyDesk}));
            }
            Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
            Admin admin = (Admin) this.adminServiceDao.getById(adminId);
            AdminLog adminLog = new AdminLog(admin.getUsername(), content.toString(), 1, admin.getType(), contentEn.toString());
            this.adminLogServiceDao.addAdminLog(adminLog);
        }
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        return result;
    }

    public Map<String, Object> deleteJoyDesk(int deskId, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        List<JoyDesk> joyDesks = this.joyDeskServiceDao.getJoyDesks();
        JoyDesk deleteDesk = null;
        RoomStatus rs = GameParameterAssist.bD;
        for (JoyDesk joyDesk : joyDesks) {
            if (joyDesk.getId() == deskId) {
                joyDesks.remove(joyDesk);
                deleteDesk = joyDesk;
                this.joyDeskServiceDao.deleteById(deskId);
                recordDeleteDesk(GameTypeEnums.GT_6.getType(), deskId, deleteDesk.getExchange());
                if (joyDesk.getModeId() == 1) {
                    rs.roomStartNum7 -= 1;
                    rs.roomRemainNum7 += 1;
                    break;
                }
                if (joyDesk.getModeId() == 2) {
                    rs.roomStartNum8 -= 1;
                    rs.roomRemainNum8 += 1;
                    break;
                }
                if (joyDesk.getModeId() != 3) {
                    break;
                }
                rs.roomStartNum9 -= 1;
                rs.roomRemainNum9 += 1;
                break;
            }
        }
        for (Map.Entry<Integer, IoSession> entry : GameParameterAssist.be.entrySet()) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(entry.getValue(), "syncRoomStatus", new Object[]{rs}));
        }
        String content = "欢乐牛牛：删除了ID为 " + deskId + " 的桌子";
        String contentEn = "Joy ：Delete a table which ID is " + deskId;
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content, 1, admin.getType(), contentEn);
        this.adminLogServiceDao.addAdminLog(adminLog);
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        for (IoSession s : com.miracle9.game.server.message.JoySocketHandler.x) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/deleteDesk", new Object[]{deleteDesk}));
        }
        SystemConfig config = this.systemConfigServiceDao.getSystemConfig();
        if ((config.getOpenJoyGame() == 1) && (rs.roomStartNum7 == 0) && (rs.roomStartNum8 == 0) && (rs.roomStartNum9 == 0)) {
            this.systemConfigServiceDao.ifTypeUpdate(GameTypeEnums.GT_6.getType(), 0);
            gameRunNotice();
        }
        GameParameterAssist.aQ.remove(deskId);
        return result;
    }

    public JoyDesk[] getJoyDeskList(IoSession session) {
        JoyDesk[] arrJoyDesk = getJoyDeskList();
        return arrJoyDesk;
    }

    public JoyDesk[] getJoyDeskList() {
        List<JoyDesk> joyDesks = this.joyDeskServiceDao.getJoyDesks();
        for (JoyDesk joyDesk : joyDesks) {
            joyDesk.setOnlineNumber(0);
            joyDesk.setModeId(joyDesk.getModeId());
            List<User> users = GameParameterAssist.aQ.get(joyDesk.getId());
            if (users != null) {
                joyDesk.setOnlineNumber(users.size());
            }
        }
        return joyDesks.toArray(new JoyDesk[0]);
    }

    public User[] getJoyDeskUser(int id, IoSession session) {
        List<User> users = GameParameterAssist.aQ.get(id);
        if (users == null) {
            users = new ArrayList<>();
        }
        JoyDesk newJoyDesk = null;
        List<JoyDesk> joyDesks = this.joyDeskServiceDao.getJoyDesks();
        for (JoyDesk joyDesk : joyDesks) {
            if (joyDesk.getId() == id) {
                newJoyDesk = joyDesk;
            }
        }
        for (User u : users) {
            User user = (User) this.userServiceDao.getById(u.getId());
            u.setGameGold(user.getGameGold());
            u.setExpeGold(user.getExpeGold());
            if (newJoyDesk.getRoomId() == 1) {
                u.setCurrentGameScore(user.getExpeScore());
            } else {
                u.setCurrentGameScore(user.getGameScore());
            }
            u.setPromoterId(user.getPromoterId());
            u.setPromoterName(user.getPromoterName());
            u.setNickname(user.getNickname());
        }
        return (User[]) users.toArray(new User[0]);
    }

    public Map<String, Object> getJoyDeskData(int id, IoSession session) {
        JoyDesk joyDesk = (JoyDesk) this.joyDeskServiceDao.getById(id);
        Map<String, Object> result = new HashMap<>();
        result.put("sumYaFen", joyDesk.getSumYaFen());
        result.put("sumDeFen", joyDesk.getSumDeFen());
        Integer nCurrentJackpotScore = GameParameterAssist.J.get(id);
        if (nCurrentJackpotScore == null) {
            nCurrentJackpotScore = 0;
        }
        result.put("currentJackpotScore", nCurrentJackpotScore);
        return result;
    }

    public Map<String, Object> cleanJoyDeskData(int id, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        this.joyDeskServiceDao.UpdateSumIfById(id);
        String content = "欢乐牛牛：清零了ID为 " + id + " 桌子的总押分和总得分";
        String contentEn = "Joy : Clean up the total bet and total score of the table which ID is " + id;
        Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
        Admin admin = (Admin) this.adminServiceDao.getById(adminId);
        AdminLog adminLog = new AdminLog(admin.getUsername(), content, 1, admin.getType(), contentEn);
        this.adminLogServiceDao.addAdminLog(adminLog);
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        return result;
    }

    public Pager getJoyDeskResult(int id, String startDate, String endDate, Pager pager, IoSession session) {
        if ("".equals(pager.getOrderBy())) {
            pager.setOrderBy("datetime");
            pager.setOrder("desc");
        }
        endDate = MyUtil.DateByDayCalendar(endDate, 1);
        pager = this.joyDeskResultServiceDao.getByDeskIdAndInterval(id, startDate, endDate, pager);
        Object[] os = pager.getList();
        Object[] array;
        int length = (array = os).length;
        for (int i = 0; i < length; i++) {
            Object o = array[i];
            JoyDeskResult deskResult = (JoyDeskResult) o;
            deskResult.setResultStr(deskResult.getPoints());
        }
        return pager;
    }

    public Map<String, Object> updateJoyPrivateDeskParameter(JoyPrivateDeskParameter joyPrivateDeskParameter, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        JoyPrivateDeskParameter oldParam = this.joyPrivateDeskParameterServiceDao.getJoyPrivateDeskParameter();
        boolean isUpdate = false;
        StringBuilder content = new StringBuilder("欢乐牛牛：修改了私人桌创建条件");
        StringBuilder contentEn = new StringBuilder("Joy : Change the private desk parameter");
        if (oldParam.getEnterLimitLevel() != joyPrivateDeskParameter.getEnterLimitLevel()) {
            isUpdate = true;
            oldParam.setEnterLimitLevel(joyPrivateDeskParameter.getEnterLimitLevel());
            content.append("，疯狂加注进入等级设置修改为Lv“" + joyPrivateDeskParameter.getEnterLimitLevel() + "”");
            contentEn.append(",Change the Login level of Crazy Bet to " + joyPrivateDeskParameter.getEnterLimitLevel());
        }
        if (oldParam.getLevel() != joyPrivateDeskParameter.getLevel()) {
            isUpdate = true;
            oldParam.setLevel(joyPrivateDeskParameter.getLevel());
            content.append("，等级修改为Lv“" + joyPrivateDeskParameter.getLevel() + "”");
            contentEn.append(",Change the level to " + joyPrivateDeskParameter.getLevel());
        }
        if (oldParam.getGameGold() != joyPrivateDeskParameter.getGameGold()) {
            isUpdate = true;
            oldParam.setGameGold(joyPrivateDeskParameter.getGameGold());
            content.append("，游戏币携带修改为“" + joyPrivateDeskParameter.getGameGold() + "”");
            contentEn.append(",Change the carry of coins to " + joyPrivateDeskParameter.getGameGold());
        }
        if (isUpdate) {
            this.joyPrivateDeskParameterServiceDao.updateLevelAndGameGold(joyPrivateDeskParameter);
            this.logger.info("===================== begin send manageService/crazySet");
            for (IoSession s : com.miracle9.game.server.message.JoySocketHandler.x) {
                AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(s, "manageService/crazySet", new Object[0]));
                this.logger.info("send manageService/crazySet");
            }
            Integer adminId = Integer.valueOf(session.getAttribute("id").toString());
            Admin admin = (Admin) this.adminServiceDao.getById(adminId);
            AdminLog adminLog = new AdminLog(admin.getUsername(), content.toString(), 1, admin.getType(), contentEn.toString());
            this.adminLogServiceDao.addAdminLog(adminLog);
        }
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        return result;
    }

    public Map<String, Object> getJoyPrivateDeskParameter(IoSession session) {
        Map<String, Object> result = getJoyPrivateDeskParameter();
        return result;
    }

    public Map<String, Object> getJoyPrivateDeskParameter() {
        Map<String, Object> result = new HashMap<>();
        JoyPrivateDeskParameter joyPrivateDeskParameter = this.joyPrivateDeskParameterServiceDao.getJoyPrivateDeskParameter();
        if (joyPrivateDeskParameter == null) {
            result.put("level", 16);
            result.put("gameGold", 100000);
            result.put("enterLimitLevel", 5);
        } else {
            result.put("level", joyPrivateDeskParameter.getLevel());
            result.put("gameGold", joyPrivateDeskParameter.getGameGold());
            result.put("enterLimitLevel", joyPrivateDeskParameter.getEnterLimitLevel());
        }
        return result;
    }

    public void gameRunNotice() {
        SystemConfig config = this.systemConfigServiceDao.getSystemConfig();
        int[] gs = {config.getOpenLuckGame(), config.getOpenFishGame(), config.getOpenCardGame(), config.getOpenBulletGame(), config.getOpenMermaidGame(), config.getOpenLackGame(), config.getOpenJoyGame(), config.getOpenWaterGame()};
        for (Map.Entry<Integer, IoSession> entry : GameParameterAssist.ba.entrySet()) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(entry.getValue(), "updateRunState", new Object[]{gs}));
        }
    }

    public void recordDeleteDesk(int nGameType, int nDeskId, int nExchange) {
        RecordDeleteDesk deleteDesk = new RecordDeleteDesk(nGameType, nDeskId, nExchange);
        this.recordDeleteDeskServiceDao.save(deleteDesk);
    }

    public Map<String, Object> controlBigFish(int type, int deskId, int userId, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        Set<IoSession> sessions = SessionUtils.getSessionByGameType(type);
        for (IoSession ioSession : sessions) {
            AmfMessageSend.storageMethodOperating.notifyAllOperating(new StorageMethodEntity(ioSession, "manageService/controlBigFish", new Object[]{deskId, userId}));
        }
        return result;
    }

    public Object getHallInfoList(int gameType, IoSession session) {
        if (GameTypeEnums.GT_0.getType() == gameType) {
            return hallInfoDao.getList();
        } else if (GameTypeEnums.GT_1.getType() == gameType) {
            return fishHallInfoDao.getList();
        } else if (GameTypeEnums.GT_2.getType() == gameType) {
            return cardHallInfoDao.getList();
        } else if (GameTypeEnums.GT_3.getType() == gameType) {
            return bulletFishHallInfoDao.getList();
        } else if (GameTypeEnums.GT_4.getType() == gameType) {
            return mermaidFishHallInfoDao.getList();
        } else if (GameTypeEnums.GT_7.getType() == gameType) {
            return waterHallInfoDao.getList();
        } else if (GameTypeEnums.GT_20.getType() == gameType) {
            return liKuiFishHallInfoDao.getList();
        } else if (GameTypeEnums.GT_37.getType() == gameType) {
            return goldenCicadaFishHallInfoDao.getList();
        }  else if (GameTypeEnums.GT_42.getType() == gameType) {
            return goldSharkHallInfoDao.getList();
        } else if (GameTypeEnums.GT_92.getType() == gameType) {
            return tianGongHallInfoDao.getList();
        }
        return new ArrayList<>();
    }

    public Object updateHallInfoList(int gameType, String hallInfoList, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        result.put("success", Boolean.TRUE);
        JSONArray jsonArray = JSONArray.fromObject(hallInfoList);
        if (GameTypeEnums.GT_0.getType() == gameType) {
            List<HallInfo> list = JSONArray.toList(jsonArray, HallInfo.class);
            hallInfoDao.update(list);
            return result;
        } else if (GameTypeEnums.GT_1.getType() == gameType) {
            List<FishHallInfo> list = JSONArray.toList(jsonArray, FishHallInfo.class);
            fishHallInfoDao.update(list);
            return result;
        } else if (GameTypeEnums.GT_2.getType() == gameType) {
            List<CardHallInfo> list = JSONArray.toList(jsonArray, CardHallInfo.class);
            cardHallInfoDao.update(list);
            return result;
        } else if (GameTypeEnums.GT_3.getType() == gameType) {
            List<BulletFishHallInfo> list = JSONArray.toList(jsonArray, BulletFishHallInfo.class);
            bulletFishHallInfoDao.update(list);
            return result;
        } else if (GameTypeEnums.GT_4.getType() == gameType) {
            List<MermaidHallInfo> list = JSONArray.toList(jsonArray, MermaidHallInfo.class);
            mermaidFishHallInfoDao.update(list);
            return result;
        } else if (GameTypeEnums.GT_7.getType() == gameType) {
            List<WaterHallInfo> list = JSONArray.toList(jsonArray, WaterHallInfo.class);
            waterHallInfoDao.update(list);
            return result;
        } else if (GameTypeEnums.GT_20.getType() == gameType) {
            List<LiKuiFishHallInfo> list = JSONArray.toList(jsonArray, LiKuiFishHallInfo.class);
            liKuiFishHallInfoDao.update(list);
            return result;
        } else if (GameTypeEnums.GT_37.getType() == gameType) {
            List<GoldenCicadaFishHallInfo> list = JSONArray.toList(jsonArray, GoldenCicadaFishHallInfo.class);
            goldenCicadaFishHallInfoDao.update(list);
            return result;
        }  else if (GameTypeEnums.GT_42.getType() == gameType) {
            List<GoldSharkHallInfo> list = JSONArray.toList(jsonArray, GoldSharkHallInfo.class);
            goldSharkHallInfoDao.update(list);
            return result;
        } else if (GameTypeEnums.GT_92.getType() == gameType) {
            List<TianGongHallInfo> list = JSONArray.toList(jsonArray, TianGongHallInfo.class);
            tianGongHallInfoDao.update(list);
            return result;
        }
        result.put("success", Boolean.FALSE);
        return result;
    }

    public Map<String, Object> getPushInfo( int deskId,int type, IoSession session) {
        Map<String, Object> result = new HashMap<>();
        result.put("success", Boolean.TRUE);
        result.put("message", "");
        FishDesk desks = this.fishDeskServiceDao.getFishDesk(deskId);
        String appName = type+"";
        String streamName = desks.getId()+"";
        //返回视频播流地址
        String url = TxLiveUtil.generate_push_url(appName, streamName);
        result.put("pushUrl", url);
        return result;
    }

}
